Changeset 1914
- Timestamp:
- 08/22/10 01:54:08 (14 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/conv.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1908 r1914 38 38 $(LI $(BUGZILLA 4345): More flexible std.array.array.) 39 39 $(LI $(BUGZILLA 4363): Some phobos ranges are not forward ranges (but should be).) 40 40 $(LI $(BUGZILLA 4381): Length attribute for std.typecons.Tuple.) 41 41 $(LI $(BUGZILLA 4387): std.range.Cycle assumes lvalue elements.) 42 42 $(LI $(BUGZILLA 4388): std.range.Radial assumes lvalue elements.) 43 43 $(LI $(BUGZILLA 4403): std.range.FrontTransversal assumes lvalue elements.) 44 44 $(LI $(BUGZILLA 4404): std.range.Transversal assumes lvalue elements.) 45 45 $(LI $(BUGZILLA 4455): Taking the sqrt of an integer shouldn't require an explicit cast.) 46 46 $(LI $(BUGZILLA 4464): std.range.take does not always return Take!R.) 47 47 $(LI $(BUGZILLA 4603): array(iota(1, 0)) error.) 48 $(LI $(BUGZILLA 4700): to!float("0") fails) 48 49 ) 49 50 ) 50 51 51 52 52 53 <div id=version> 53 54 $(UL 54 55 $(NEW 049) 55 56 $(NEW 048) 56 57 $(NEW 047) 57 58 $(NEW 046) trunk/phobos/std/conv.d
r1895 r1914 1225 1225 } 1226 1226 char sign = 0; /* indicating + */ 1227 1227 switch (p.front) 1228 1228 { 1229 1229 case '-': sign++; goto case '+'; 1230 1230 case '+': p.popFront(); enforce(!p.empty, 1231 1231 new ConvError("error converting input to floating point")); 1232 1232 default: {} 1233 1233 } 1234 1234 1235 const bool isHex = p.front == '0' 1236 && (p.popFront(), p.front == 'x' || p.front == 'X'); 1235 bool isHex = p.front == '0'; 1236 if(isHex) 1237 { 1238 p.popFront(); 1239 if(p.empty) 1240 { 1241 return (sign) ? -0 : 0; 1242 } 1243 1244 isHex = isHex && (p.front == 'x' || p.front == 'X'); 1245 } 1237 1246 1238 1247 real ldval = 0.0; 1239 1248 char dot = 0; /* if decimal point has been seen */ 1240 1249 int exp = 0; 1241 1250 long msdec = 0, lsdec = 0; 1242 1251 ulong msscale = 1; 1243 1252 1244 1253 if (isHex) 1245 1254 { 1246 1255 int guard = 0; … … 2281 2290 f = to!float( "123e+2" ); 2282 2291 assert( f == 123e+2f ); 2283 2292 2284 2293 f = to!float( "123e-2" ); 2285 2294 assert( f == 123e-2f ); 2286 2295 f = to!float( "123." ); 2287 2296 assert( f == 123.f ); 2288 2297 f = to!float( ".456" ); 2289 2298 assert( f == .456f ); 2290 2299 2300 assert(to!float("0") == 0f); 2301 assert(to!float("-0") == -0f); 2302 2291 2303 // min and max 2292 2304 try 2293 2305 { 2294 2306 f = to!float("1.17549e-38"); 2295 2307 assert(feq(cast(real)f, cast(real)1.17549e-38)); 2296 2308 assert(feq(cast(real)f, cast(real)float.min_normal)); 2297 2309 f = to!float("3.40282e+38"); 2298 2310 assert(to!string(f) == to!string(3.40282e+38)); 2299 2311 } 2300 2312 catch (ConvError e) // strtof() bug on some platforms … … 2339 2351 assert( d == 123e2); 2340 2352 d = to!double( "123e-2" ); 2341 2353 assert( d == 123e-2 ); 2342 2354 d = to!double( "123." ); 2343 2355 assert( d == 123. ); 2344 2356 d = to!double( ".456" ); 2345 2357 assert( d == .456 ); 2346 2358 d = to!double( "1.23456E+2" ); 2347 2359 assert( d == 1.23456E+2 ); 2348 2360 2361 assert(to!double("0") == 0.0); 2362 assert(to!double("-0") == -0.0); 2363 2349 2364 // min and max 2350 2365 try 2351 2366 { 2352 2367 d = to!double("2.22508e-308"); 2353 2368 assert(feq(cast(real)d, cast(real)2.22508e-308)); 2354 2369 assert(feq(cast(real)d, cast(real)double.min_normal)); 2355 2370 d = to!double("1.79769e+308"); 2356 2371 assert(to!string(d) == to!string(1.79769e+308)); 2357 2372 assert(to!string(d) == to!string(double.max)); 2358 2373 } … … 2400 2415 assert(feq(r, 1.23L)); 2401 2416 r = to!real("123."); 2402 2417 assert(r == 123L); 2403 2418 r = to!real(".456"); 2404 2419 assert(r == .456L); 2405 2420 2406 2421 r = to!real("1.23456e+2"); 2407 2422 assert(feq(r, 1.23456e+2L)); 2408 2423 r = to!real(to!string(real.max / 2L)); 2409 2424 assert(to!string(r) == to!string(real.max / 2L)); 2425 2426 assert(to!real("0") == 0.0L); 2427 assert(to!real("-0") == -0.0L); 2410 2428 2411 2429 // min and max 2412 2430 try 2413 2431 { 2414 2432 r = to!real(to!string(real.min_normal)); 2415 2433 assert(to!string(r) == to!string(real.min_normal)); 2416 2434 r = to!real(to!string(real.max)); 2417 2435 assert(to!string(r) == to!string(real.max)); 2418 2436 } 2419 2437 catch (ConvError e) // strtold() bug on some platforms
