Don't ask me what use case made me notice this, but the 
http://www.sqlite.org/lang_corefunc.html documentation for abs(), as of 12:29PM 
EDT on 10/26/2013, is only about 99.999999999999999989157978275145% accurate.

"If X is the integer -9223372036854775807 then abs(X) throws an integer 
overflow error since there is no equivalent positive 64-bit two complement 
value."

It's off by one: X is actually -9223372036854775808. -9223372036854775807 is 
the lowest number *with* a positive 64-bit two complement.

On Win7 64-bit:

sqlite> .version
SQLite 3.8.1 2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a
sqlite> SELECT ABS(-9223372036854775807); --docs claim will throw error; doesn't
9223372036854775807
sqlite> SELECT ABS(-9223372036854775808); --does throw error
Error: integer overflow
sqlite> SELECT ABS(-9223372036854775809); --now we're in floating point
9.22337203685478e+18

Happy to put my 0.00000000000000000010842021724855 cents in,
GC                                        
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to