Comment #0 by bearophile_hugs — 2010-04-24T16:09:02Z
The toString() of BigInt is not handy to print bigintegers during debugging. I have had to create a function like:
const(char)[] bigIntRepr(BigInt i) {
const(char)[] result;
i.toString((const(char)[] s){ result = s; }, "d");
return result;
}
Note that this doesn't work (Access violation, I don't know why):
const(char)[] bigIntRepr(BigInt i) {
const(char)[] result;
i.toString((const(char)[] s){ result = s; }, null);
return result;
}
My suggestion is to change the signature of BigInt.toString() from this:
void toString(void delegate(const (char)[]) sink, string formatString) const {
To something like this:
string toString(void delegate(string) sink=null, string formatString="d") const {
And make it return a string filled with the decimal representation when sink is null; and to return an empty string when sink!=null.
------------------------
Eventually the signature can even become:
string toString(void delegate(string) sink=null, string formatString="d", string thousands="") const {
So if thousands="_" the number gets represented as:
"100_000_000_000"
But this is less important.
Comment #1 by bearophile_hugs — 2010-11-19T10:06:24Z