[phobos] BigInt from Tango

Andrei Alexandrescu andrei at erdani.com
Thu Mar 18 23:20:43 PDT 2010


On 03/18/2010 10:46 PM, Don Clugston wrote:
> I've converted my BigInt module from Tango to Phobos2. It's a great
> test of the new operator overloading!
> After 2.042 comes out, I'd like to add it to Phobos.

Awesome! How do the operators hold?

> A couple of issues:
> (1) We need somewhere in Phobos for implementation code (of which
> there is a considerable amount for BigInt).
>
> I propose std.internal.math.XXX; for all math related modules. This
> would keep everything tidy and hidden.
> None of this will be user-visible.

Sounds good.

> (2)  Syntax for conversion to string is undecided. Strawman:
>
>   void toString(void delegate(const(char)[]) sink, string format);
>
> where format is currently limited to:
>
> d    for decimal
> x    for lower case hex
> X    for upper case hex

s or null for "whatever" for conformity.

> but will be extended in the future. If format is "", defaults to decimal.
> Sink takes a const(char)[] so that BigInt can keep reusing the same buffer.
>
> Eventually, whatever is chosen will require some changes to
> std.format, but I'd just like to get a reasonable first cut for the
> initial release.

That's fine; we need to look again at std.format anyway.

Speaking of which - do we have good code for parsing and writing 
floating point numbers? I need it for unformat().


Andrei


More information about the phobos mailing list