SQLite

Check-in [438e1577d0]
Login

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

Overview
Comment:Changes to internal AtoF to improve "accuracy" when measured against built-in GCC atof().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 438e1577d0f9ceb2851ee0df0df18f0229eca491
User & Date: shane 2009-09-07 02:46:32.000
Context
2009-09-07
03:48
Attempt to handle numbers at the limits of the IEEE 754 range better (nan.test now passes). (check-in: 2a74ae1969 user: shane tags: trunk)
02:46
Changes to internal AtoF to improve "accuracy" when measured against built-in GCC atof(). (check-in: 438e1577d0 user: shane tags: trunk)
2009-09-03
16:23
Add the "unix-wfl" VFS that does whole-file locking in order to help NFS do better cache coherency. (check-in: 2aeab80e5b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/util.c.
360
361
362
363
364
365
366


367
368
369
370
371
372
373
374
375
376

377
378
379
380
381
382
383
384
385
    /* In the IEEE 754 standard, zero is signed.
    ** Add the sign if we've seen at least one digit */
    result = (sign<0 && nDigits) ? -(double)0 : (double)0;
  } else {
    /* attempt to reduce exponent */
    if( esign>0 ){
      while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;


    }

    /* 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;
      while( e>=16 ){ scale *= 1.0e+16; e -= 16; }

      while( e>=4 ){ scale *= 1.0e+4; e -= 4; }
      while( e>=1 ){ scale *= 1.0e+1; e -= 1; }
      if( esign<0 ){
        result = s / scale;
      }else{
        result = s * scale;
      }
    } else {
      result = (double)s;







>
>









|
>
|
|







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
    /* In the IEEE 754 standard, zero is signed.
    ** Add the sign if we've seen at least one digit */
    result = (sign<0 && nDigits) ? -(double)0 : (double)0;
  } else {
    /* attempt to reduce exponent */
    if( esign>0 ){
      while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;
    }else{
      while( !(s%10) && e>0 ) e--,s/=10;
    }

    /* 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;