[Issue 4673] New: Bug in std.string (isNumeric)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 18 03:08:25 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4673
Summary: Bug in std.string (isNumeric)
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: petitv.isat at gmail.com
--- Comment #0 from Petit Vincent <petitv.isat at gmail.com> 2010-08-18 12:08:20 CEST ---
Created an attachment (id=725)
Source code (from description)
Hi. I was doing some recursivity with D and I probably found a bug with the
isNumeric() function.
Here's the source code (also in attach) :
import std.stdio;
import std.string;
import std.conv;
int main(string[] args)
{
if(args.length > 1)
{
int number;
foreach(item; args)
{
if(isNumeric(item))
{
number = parse!(uint)(item); // seems to have a bug with 'L'
and 'F' values
writeln("Facto of ", number, " is ", facto(number));
}
}
}
else
{
writeln("You must specified a number.");
}
return 0;
}
uint facto(uint number)
{
uint result;
if(number <= 1)
{
result = 1;
}
else
{
result = number * facto(number - 1);
}
return result;
}
See the result when running the compiled executables with these args : 5 8 A F
>facto 5 8 A F
Facto of 5 is 120
Facto of 8 is 40320
std.conv.ConError : std.conv(1070) : Can't convert 'F' of type string to type
uint
It seems that "F" and "L" alone are recognized as Float and Long specifier but
... there's no digit. I accept that 0F, 1L are digits but F and L alone are
not.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list