SQLite4
Check-in [2552bc97ef]
Not logged in

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

Overview
Comment:Create sqlite4_num_from_int64.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | num_work
Files: files | file ages | folders
SHA1: 2552bc97ef445f86158e57f6e21d4a3bf4fe94ad
User & Date: peterreid 2013-02-09 05:32:33
Context
2013-02-09
05:33
Make sqlite4_num's exponent signed. check-in: b320c13e42 user: peterreid tags: num_work
05:32
Create sqlite4_num_from_int64. check-in: 2552bc97ef user: peterreid tags: num_work
05:31
Prevent reading out of bounds in sqlite4_num_from_text. Parsing 'in' (prefix of 'inf') with byte count 2 triggered the bug. check-in: 408475b607 user: peterreid tags: num_work
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/math.c.

   386    386     return r;
   387    387     
   388    388   not_a_valid_number:
   389    389     r.e = SQLITE4_MX_EXP+1;
   390    390     r.m = 0;
   391    391     return r;  
   392    392   }
          393  +
          394  +/*
          395  +** Convert an sqlite4_int64 to a number and return that number.
          396  +*/
          397  +sqlite4_num sqlite4_num_from_int64(sqlite4_int64 n){
          398  +  sqlite4_num r;
          399  +  r.approx = 0;
          400  +  r.e = 0;
          401  +  r.sign = n < 0;
          402  +  if( n>=0 ){
          403  +    r.m = n;
          404  +  }else if( n!=SMALLEST_INT64 ){
          405  +    r.m = -n;
          406  +  }else{
          407  +    r.m = 1+(u64)LARGEST_INT64;
          408  +  }
          409  +  return r;
          410  +}
   393    411   
   394    412   /*
   395    413   ** Convert an integer into text in the buffer supplied. The
   396    414   ** text is zero-terminated and right-justified in the buffer.
   397    415   ** A pointer to the first character of text is returned.
   398    416   **
   399    417   ** The buffer needs to be at least 21 bytes in length.