digitalmars.D.bugs - base 1 bug in std.string.toString?
- nobody (10/10) Aug 21 2006 int main(char[][] args)
- Frits van Bommel (14/28) Aug 21 2006 From the docs: (http://www.digitalmars.com/d/phobos/std_string.html)
- Frank Benoit (11/16) Aug 21 2006 I only want to comment that the missing return statement can also be the
int main(char[][] args)
{
dout.writeLine(toString(1uL,1u));
assert( toString(12uL,1u).length == 12 );
}
This produces:
1000000000000000000000000000000000000000000000000000000000000000000000
Error: Assert Failure example(4)
When I think it should produce
1
Aug 21 2006
nobody wrote:
int main(char[][] args)
{
dout.writeLine(toString(1uL,1u));
assert( toString(12uL,1u).length == 12 );
}
This produces:
1000000000000000000000000000000000000000000000000000000000000000000000
Error: Assert Failure example(4)
When I think it should produce
1
From the docs: (http://www.digitalmars.com/d/phobos/std_string.html)
------
char[] toString(long value, uint radix);
char[] toString(ulong value, uint radix);
Convert value to string in radix radix.
radix must be a value from 2 to 36. [...]
------
So you're just calling it with an invalid parameter value.
Hint: 1 wouldn't be a valid digit in base 1, just like 2 isn't one in
base 2, A isn't one in base 10, etc.
So the only valid digit would be 0, and since extra leading zeroes are
ignored, the only value that can possibly be represented in base 1 is 0
itself.
Aug 21 2006
nobody schrieb:
int main(char[][] args)
{
dout.writeLine(toString(1uL,1u));
assert( toString(12uL,1u).length == 12 );
}
I only want to comment that the missing return statement can also be the
source of the assertion. Either
void main(){
...
}
or
int main( char[][] args ){
...
return 0;
}
Aug 21 2006









Frits van Bommel <fvbommel REMwOVExCAPSs.nl> 