atof & atoi
torhu
fake at address.dude
Fri Mar 2 16:13:54 PST 2007
Kagan Kayal wrote:
> 1. The standard atof or atoi functions convert any garbage like "abc" to zero.
> 2. If the input string represents a valid number, but too big;
> - atof returns inf. This is not too bad but you find out this either when you convert it back to a string, which returns "inf" or when you explicitly test with the isinf function. That may be too late...
> - atoi returns an integer value, which is something wrong.
>
> I believe in both cases they should throw an exception.
atof and atoi are from the C library, and behave according to the C
standard. std.conv has functions that throw exceptions on errors.
More information about the Digitalmars-d-bugs
mailing list