/ Check-in [2a74ae19]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Attempt to handle numbers at the limits of the IEEE 754 range better (nan.test now passes).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a74ae1969aeec93576a44e11177677e6f3cea9c
User & Date: shane 2009-09-07 03:48:53
Context
2009-09-07
04:38
Warning cleanup from the MSVC compile. check-in: 26cd015c user: shane tags: trunk
03:48
Attempt to handle numbers at the limits of the IEEE 754 range better (nan.test now passes). check-in: 2a74ae19 user: shane tags: trunk
02:46
Changes to internal AtoF to improve "accuracy" when measured against built-in GCC atof(). check-in: 438e1577 user: shane tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/util.c.

371
372
373
374
375
376
377











378
379
380
381
382
383
384
385

386
387
388
389
390
391
392
    /* adjust the sign of significand */
    s = sign<0 ? -s : s;

    /* if exponent, scale significand as appropriate
    ** and store in result. */
    if( e ){
      double scale = 1.0;











      /* 1.0e+22 is the largest power of 10 than can be 
      ** represented exactly. */
      while( e%22 ) { scale *= 1.0e+1; e -= 1; }
      while( e>0 ) { scale *= 1.0e+22; e -= 22; }
      if( esign<0 ){
        result = s / scale;
      }else{
        result = s * scale;

      }
    } else {
      result = (double)s;
    }
  }

  /* store the result */







>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
>







371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
    /* adjust the sign of significand */
    s = sign<0 ? -s : s;

    /* if exponent, scale significand as appropriate
    ** and store in result. */
    if( e ){
      double scale = 1.0;
      /* attempt to handle extremely small/large numbers better */
      if( e>307 && e<342 ){
        while( e%308 ) { scale *= 1.0e+1; e -= 1; }
        if( esign<0 ){
          result = s / scale;
          result /= 1.0e+308;
        }else{
          result = s * scale;
          result *= 1.0e+308;
        }
      }else{
        /* 1.0e+22 is the largest power of 10 than can be 
        ** represented exactly. */
        while( e%22 ) { scale *= 1.0e+1; e -= 1; }
        while( e>0 ) { scale *= 1.0e+22; e -= 22; }
        if( esign<0 ){
          result = s / scale;
        }else{
          result = s * scale;
        }
      }
    } else {
      result = (double)s;
    }
  }

  /* store the result */