View previous topic :: View next topic |
Author |
Message |
bobef
Joined: 05 Jun 2005 Posts: 269
|
Posted: Tue Feb 26, 2008 6:24 am Post subject: Small Itoa bug |
|
|
Code: | template Itoa(int i)
{
static if(i < 0)
const char[] Itoa = "-" ~ Itoa!(-i);
else static if(i > 10)
const char[] Itoa = Itoa!(i / 10) ~ "0123456789"[i % 10];
else
const char[] Itoa = "" ~ "0123456789"[i % 10];
} |
Code: | else static if(i > 10) | must be Code: | else static if(i >= 10) | otherwise Itoa!(10) is returning 0. |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Tue Feb 26, 2008 9:17 am Post subject: |
|
|
:O
Thanks! |
|
Back to top |
|
|
|