FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Small Itoa bug

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Tue Feb 26, 2008 6:24 am    Post subject: Small Itoa bug Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Tue Feb 26, 2008 9:17 am    Post subject: Reply with quote

:O

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group