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

Overview
Comment:Fix sqlite4_num_to_text when formatting an integer with a negative exponent. It was leaving an uninitialized byte in the destination string.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | num_work
Files: files | file ages | folders
SHA1: 3cac6cdb864a4ecbdea82bc5441bc80914cb2275
User & Date: peterreid 2013-02-14 01:51:45.349
Context
2013-02-14
15:32
Fold in Peter Reid's fixes and enhancements to the sqlite4_num object. check-in: 8ede88c1df user: drh tags: trunk
01:51
Fix sqlite4_num_to_text when formatting an integer with a negative exponent. It was leaving an uninitialized byte in the destination string. Leaf check-in: 3cac6cdb86 user: peterreid tags: num_work
2013-02-11
14:03
Add test fixture functions for sqlite4_num_isinf and sqlite4_num_isnan, and some related test cases. check-in: 58a9cfcb39 user: peterreid tags: num_work
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/math.c.
497
498
499
500
501
502
503
504
505




506
507
508
509
510
511
512
497
498
499
500
501
502
503


504
505
506
507
508
509
510
511
512
513
514







-
-
+
+
+
+







    zNum += m;
    n -= m;
    removeTrailingZeros(zNum, &n);
    if( n>0 ){
      zOut[0] = '.';
      memcpy(zOut+1, zNum, n);
      nOut += n;
    }
    zOut[n+1] = 0;
      zOut[n+1] = 0;
    }else{
      zOut[0] = 0;
    }
    return nOut;
  }
  if( x.e<0 && x.e >= -n-5 ){
    /* Values less than 1 and with no more than 5 subsequent zeros prior
    ** to the first significant digit.  Ex:  0.0000012345 */
    int j = -(n + x.e);
    memcpy(zOut, "0.", 2);
Changes to test/num.test.
75
76
77
78
79
80
81
82
83
84
85









86
75
76
77
78
79
80
81




82
83
84
85
86
87
88
89
90
91







-
-
-
-
+
+
+
+
+
+
+
+
+

do_test num-5.1.1 {
  sqlite4_num_to_text [sqlite4_num_mul 9 8]
} {72}

do_test num-6.1.1 {
  sqlite4_num_to_text [sqlite4_num_div 6 5]
} {1.2}




do_test num-6.1.2 {
  sqlite4_num_compare 2 [sqlite4_num_div 2 1]
} {equal}
do_test num-6.1.3 {
  sqlite4_num_to_text [sqlite4_num_div 2 1]
} {2}
do_test num-6.1.4 {
  sqlite4_num_to_text [sqlite4_num_div 22 10]
} {2.2}
finish_test