--------------------------------------------------------
1: static int sqlite3IntFloatCompare(i64 i, double r){
2: if( sizeof(LONGDOUBLE_TYPE)>8 ){
3: LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
4: if( x<r ) return -1;
5: if( x>r ) return +1;
6: return 0;
7: }else{
8: i64 y;
9: double s;
10: if( r<-9223372036854775808.0 ) return +1;
11: if( r>9223372036854775807.0 ) return -1;
12: y = (i64)r;
13: if( i<y ) return -1;
14: if( i>y ){
15: if( y==SMALLEST_INT64 && r>0.0 ) return -1;
16: return +1;
17: }
18: s = (double)i;
19: if( s<r ) return -1;
20: if( s>r ) return +1;
21: return 0;
22: }
23: }
--------------------------------------------------------
Line 11: the value 9223372036854775807.0 is unrepresentable as a double.
The compiler uses the approximation 9223372036854775808.0,
so the condition is in fact 'if( r>9223372036854775808.0 )'.
Line 12: when r=9223372036854775808.0 then y=SMALLEST_INT64
and this special case is handled by the condition on line 15.
But if the condition in line 11 were 'if( r>=9223372036854775808.0 )'
then for r=9223372036854775808.0 the function would return -1
before assigning r to y, so the condition on line 15 would be unnecessary.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users