Parse issue

James Miller james at aatch.net
Sun Mar 11 19:42:28 PDT 2012


On 12 March 2012 14:39, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> Does anyone else think this should be fixed?
>
> import std.conv;
>
> void main()
> {
>    string s1 = "ff";
>    string s2 = "0xff";
>
>    assert(parse!uint(s1, 16) == 0xff);  // ok
>    assert(parse!uint(s2, 16) == 0xff);  // fail, it's 0
> }
>
> I think parse should pop the first two characters if the string starts with 0x.
>
>
> Side-note, it would be nice if std.string.isNumeric took a radix. :)

I agree, seems like a bug to me.

--
James Miller


More information about the Digitalmars-d-learn mailing list