Mercurial > projects > ldc
view test/bug55.d @ 137:ce7b81fb957f trunk
[svn r141] fixed more problems with classinfo
moved more IR state out of the AST classes
author | lindquist |
---|---|
date | Fri, 18 Jan 2008 16:42:16 +0100 |
parents | 70d6113eeb8c |
children | d9d5d59873d8 |
line wrap: on
line source
module bug55; int atoi(char[] s) { int i, fac=1; bool neg = (s.length) && (s[0] == '-'); char[] a = neg ? s[1..$] : s; foreach_reverse(c; a) { i += (c-'0') * fac; fac *= 10; } return !neg ? i : -i; } void main() { printf("64213 = %d\n", atoi("64213")); printf("-64213 = %d\n", atoi("-64213")); assert(atoi("64213") == 64213); assert(atoi("-64213") == -64213); }