[Issue 18290] std.conv.parse throws ConvOverflowException for negative values in hex

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 22 09:12:10 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18290

--- Comment #2 from Răzvan Ștefănescu <rumbu at rumbu.ro> ---
(In reply to Tiberiu Lepadatu from comment #1)
> (In reply to Răzvan Ștefănescu from comment #0)
> > string input = "80000000";
> > auto x = parse!int(input, 16);
> > //ConvOverflowException
> 
> I feel that this is not a bug. To show that you
> are using a hex string you must use "0x" in front.
> If you write "0x80000000" instead of "80000000"
> there is no bug.

parsing 0x80000000 will read only the "0" before x, which is not the intended
behavior, therefore x will become 0, not -2147483648.

In order to show that I am using a hex string, I specify the radix (16). To go
further, how do I parse a string with radix 7? How do I prefix the string?

--


More information about the Digitalmars-d-bugs mailing list