Changeset 126 for trunk/meta/conv.d
- Timestamp:
- 01/26/06 04:45:25 (3 years ago)
- Files:
-
- trunk/meta/conv.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/meta/conv.d
r118 r126 25 25 const char [] itoa = decimaldigit!(n); 26 26 } else { 27 const char [] itoa = .itoa!(n/10L) ~ decimaldigit!(n%10L);27 const char [] itoa = itoa!(n/10L) ~ decimaldigit!(n%10L); 28 28 } 29 29 } … … 34 34 const char [] toHexString = hexdigit!(n); 35 35 } else { 36 const char [] toHexString = .toHexString!(n >> 4) ~ hexdigit!(n&0xF);36 const char [] toHexString = toHexString!(n >> 4) ~ hexdigit!(n&0xF); 37 37 } 38 38 } … … 57 57 const int countleadingdigits=indx; 58 58 } else static if (indx==0 && s[indx]=='-') { 59 const int countleadingdigits = .countleadingdigits!(s, indx+1);59 const int countleadingdigits = countleadingdigits!(s, indx+1); 60 60 } else static if (!isdigit!( (s[indx]) )) { 61 61 const int countleadingdigits=indx; 62 62 } else { 63 const int countleadingdigits = .countleadingdigits!(s, indx+1);63 const int countleadingdigits = countleadingdigits!(s, indx+1); 64 64 } 65 65 } … … 82 82 } 83 83 } else static if ( s[p]=='.'|| (p==0 && s[p]=='-') ) { 84 const int sigFigs = .sigFigs!(s, p+1, stillzero);84 const int sigFigs = sigFigs!(s, p+1, stillzero); 85 85 } else static if (s[p]=='0' && stillzero) { 86 const int sigFigs = .sigFigs!(s, p+1, stillzero);86 const int sigFigs = sigFigs!(s, p+1, stillzero); 87 87 } else static if ( isdigit!((s[p])) ) { 88 const int sigFigs = 1 + .sigFigs!(s, p+1, false);88 const int sigFigs = 1 + sigFigs!(s, p+1, false); 89 89 } else static if ( s[p]=='e' || s[p]=='E' ) { 90 90 // abort once we reach the exponent … … 101 101 { 102 102 static if (maxdigs==0 || x==0) const char [] afterdec = ""; 103 else const char [] afterdec = .decimaldigit!(cast(int)(x*10)) ~ .afterdec!(x*10-cast(int)(x*10), maxdigs-1);103 else const char [] afterdec = decimaldigit!(cast(int)(x*10)) ~ afterdec!(x*10-cast(int)(x*10), maxdigs-1); 104 104 } 105 105 … … 134 134 else static if (x<0) const char [] pcvt = "-" ~ .pcvt!(-x); 135 135 else static if (x==real.infinity) const char [] pcvt = "inf"; 136 else const char [] pcvt = "0x1." ~ .toHexString!(cast(ulong)(0x1000000 *(.binaryMantissa!(x)-1.0)) ) ~ "p" ~ itoaWithSign!(.binaryExponent!(x));136 else const char [] pcvt = "0x1." ~ toHexString!(cast(ulong)(0x1000000 *(binaryMantissa!(x)-1.0)) ) ~ "p" ~ itoaWithSign!(binaryExponent!(x)); 137 137 } 138 138 139 139 version(testmeta) { 140 140 private import meta.strhacks; 141 142 static assert( streq!(itoa!(5638), "5638")); 141 143 142 static assert( streq!(pcvt!(0x1.12345p954L), "0x1.123450p+954") ); 144 143 static assert( streq!(fcvt!(12.345), "12.345") ); 144 145 145 static assert( atoi!("3580abc")==3580); 146 146 static assert( atoi!("-0326")==-326);
