/ Check-in [6ba4be66be]
Login

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

Overview
Comment:Enhancements to the printf() logic in order to render a negative zero with a minus sign.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | negative-zero
Files: files | file ages | folders
SHA3-256: 6ba4be66be90799ab0e1edc08c5c09bea239a85027ad0ca1f42818fc2580af4d
User & Date: drh 2019-06-12 20:11:34
Context
2019-06-12
20:11
Enhancements to the printf() logic in order to render a negative zero with a minus sign. Leaf check-in: 6ba4be66be user: drh tags: negative-zero
13:49
Handle expressions like "expr IS TRUE COLLATE xyz" in the same way as "expr IS TRUE". Fix for [4d01eda8115b10d1]. check-in: 5c6146b56a user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/printf.c.

100
101
102
103
104
105
106







107
108
109
110
111
112
113
...
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
};

/* Floating point constants used for rounding */
static const double arRound[] = {
  5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05,
  5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10,
};








/*
** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
** conversions will work.
*/
#ifndef SQLITE_OMIT_FLOATING_POINT
/*
................................................................................
        }else{
          realvalue = va_arg(ap,double);
        }
#ifdef SQLITE_OMIT_FLOATING_POINT
        length = 0;
#else
        if( precision<0 ) precision = 6;         /* Set default precision */
        if( realvalue<0.0 ){
          realvalue = -realvalue;
          prefix = '-';
        }else{
          prefix = flag_prefix;
        }
        if( xtype==etGENERIC && precision>0 ) precision--;
        testcase( precision>0xfff );







>
>
>
>
>
>
>







 







|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
};

/* Floating point constants used for rounding */
static const double arRound[] = {
  5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05,
  5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10,
};

/* Return TRUE if a floating point number is negative, even a negative 0 */
static int realIsNeg(double r){
  i64 x;
  memcpy(&x,&r,sizeof(x));
  return x<0;
}

/*
** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
** conversions will work.
*/
#ifndef SQLITE_OMIT_FLOATING_POINT
/*
................................................................................
        }else{
          realvalue = va_arg(ap,double);
        }
#ifdef SQLITE_OMIT_FLOATING_POINT
        length = 0;
#else
        if( precision<0 ) precision = 6;         /* Set default precision */
        if( realIsNeg(realvalue) ){
          realvalue = -realvalue;
          prefix = '-';
        }else{
          prefix = flag_prefix;
        }
        if( xtype==etGENERIC && precision>0 ) precision--;
        testcase( precision>0xfff );