Is there a good lib out there to handle large integer of know size ?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 6 15:03:33 PST 2016


On 01/06/2016 05:47 PM, H. S. Teoh via Digitalmars-d wrote:
> On Wed, Jan 06, 2016 at 05:23:12PM -0500, Andrei Alexandrescu via Digitalmars-d wrote:
>> On 1/6/16 5:18 PM, deadalnix wrote:
>>> On Wednesday, 6 January 2016 at 21:57:13 UTC, Guillaume Piolat wrote:
>>>> On Wednesday, 6 January 2016 at 21:25:45 UTC, deadalnix wrote:
>>>>> In my case, I'm interested in 160 and 256 bits integers. Using
>>>>> BigInt seems wasteful as I know the integer size I want. Do we have
>>>>> something like this around ?
>>>>
>>>> https://github.com/d-gamedev-team/gfm/blob/master/math/gfm/math/wideint.d
>>>>
>>>> public domain. Slow division. Only power-of-2 bits supported.
>>>
>>> That is awesome ! Won't do the 160 bits case, but I can deal with
>>> that.  Did you consider this as a worthy addition to phobos ? I think
>>> it is.
>>
>> Yes, we need to add that to phobos. Who could be the champion? --
>
> Here are a few things that should probably be addressed before merging
> to Phobos:
>
> - Better error message when user attempts to instantiate a wide int with
>    non-power-of-2 bits. (Currently spews a whole bunch of internal
>    compile errors.)
>
> - toString() needs to:
>    1) Be the non-allocating overload:
>
>    	void toString(scope void delegate(const(char)[]) dg) {...}
>
>    2) Output in decimal by default instead of hex.
>
> - Need a nice way of initializing wide ints from literals.
>
> - [optional] Division performance can probably be improved.

This is a good list, and not difficult to implement. Thanks! -- Andrei




More information about the Digitalmars-d mailing list