Hi all, The "99990.1 case" is still a mystery!
For clarity reasons, I have expanded line 19911 of sqlite3.c (v3.7.13) 19909: while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } 19910: while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } 19911: while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; } 19912: while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } 19913: while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } as: 19909: while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } 19910: while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } 19911: while( realvalue>=10.0 && exp<=350 ) 19912: { 19913: realvalue *= 0.1; 19914: exp++; 19915: } 19916: while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } 19917: while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } No other modification. SQLite3.c is compiled (gcc -c -g sqlite3.c) with default options ONE TIME ONLY. (Env: Int. Core i5, Win7 Pro/32, gcc 4.5, gdb 7.2) The same object module is linked to shell.o (for SQLite) and to JSDB. SQLite is then launched under GDB (run NUL "select 99990.1;", breakpoint set up accordingly). The debugging session looks like: (...) (gdb) print realvalue-99990 $6 = 0.10000000000582077 (gdb) n 19913 realvalue *= 0.1; (gdb) print realvalue-99990 $7 = 0.10000000000582077 (gdb) n 19914 exp++; (gdb) print realvalue-9999 $8 = 0.010000000002037268 (gdb) n 19913 realvalue *= 0.1; (gdb) print realvalue-9999 $9 = 0.010000000002037268 (gdb) n 19914 exp++; (gdb) print realvalue-999 $10 = 0.90100000000018099 <------ (gdb) (...) JSDB run in the same environment with the matching input: js>var db = new SQLite(); js>db.exec("select 99990.1",function(r){writeln(r)}); Here is a piece of the debugging session (same breakpoint): (...) (gdb) print realvalue-99990 $4 = 0.10000000000582077 (gdb) n 19913 realvalue *= 0.1; (gdb) print realvalue-99990 $5 = 0.10000000000582077 (gdb) n 19914 exp++; (gdb) print realvalue-9999 $6 = 0.010000000002037268 (gdb) n 19913 realvalue *= 0.1; (gdb) print realvalue-9999 $7 = 0.010000000002037268 (gdb) n 19914 exp++; (gdb) print realvalue-999 $8 = 0.90100000000029468 <------ (gdb) (...) Please note that the "realvalue" variable has identical values at the first loop pass. They only start diverging (29468/18099 = +/-60%) from the second pass! This divergence leads to a rounding error in the second case (JSDB), while SQLite(shell) properly displays the ("faked") result. So same input, same byte code... and different results! Who the heck said IT is determinist? Does anybody figure out the reason of the difference? Thanks in advance. Etienne _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users