Bug 20568 – Unable to convert string to int or uint ... if string having underscore character but work with float ....

Status
RESOLVED
Resolution
DUPLICATE
Severity
trivial
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-08T15:03:41Z
Last change time
2021-04-21T18:08:53Z
Assigned to
No Owner
Creator
apham
See also
https://issues.dlang.org/show_bug.cgi?id=9797

Comments

Comment #0 by apz28 — 2020-02-08T15:03:41Z
//Inconsistent behavior import std.conv : to; auto workWithFloat = to!float("1_000"); auto failWithInt = to!int("1_000"); auto failWithInt = to!uint("1_000");
Comment #1 by b2.temp — 2020-02-08T16:04:02Z
In theory underscores should throw when found in an argument of `to!float`. This other issue (https://issues.dlang.org/show_bug.cgi?id=9797) was closed for the rationale that is that std.conv.to is not made to handle special D flavors of number literals but is rather a generic handler. Note that octal and hexString handle underscores for another reason, that is that they were made specifically to replace literals.
Comment #2 by bugzilla — 2021-04-21T18:08:53Z
*** This issue has been marked as a duplicate of issue 15526 ***