aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordrh <>2024-12-07 19:57:30 +0000
committerdrh <>2024-12-07 19:57:30 +0000
commit9f53d0c8179a3b69f788bd31749fc7c15092be87 (patch)
tree1dc419cb0ba95c5a998196d5efb424270abfcb42 /src/util.c
parent8703642803df6dc3920239ed85654e92b4cc5451 (diff)
downloadsqlite-9f53d0c8179a3b69f788bd31749fc7c15092be87.tar.gz
sqlite-9f53d0c8179a3b69f788bd31749fc7c15092be87.zip
Yet another iteration of the solution to the floating-point conversion
problem - this what avoids complaints about oversize double values from -fsanitize. FossilOrigin-Name: fc6904a508eb732b1cb5cc12321a0d637d97e1e066a022a2c93cb50595f3a86a
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c
index e134f7a7d..ab8249c8d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -653,15 +653,15 @@ do_atof_calc:
}
rr[0] = (double)s;
- s2 = (u64)rr[0];
- rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
- if( rr[1]>1e-10*rr[0] ){
- /* On some floating-point processing units, doing the round
- ** trip from u64 to double back to u64 can give a wonky value
- ** when the original u64 is close to LARGEST_UINT64. If we
- ** did get an overly large error value, just set it to zero. */
+ assert( sizeof(s2)==sizeof(rr[0]) );
+ memcpy(&s2, &rr[0], sizeof(s2));
+ if( s2<=0x43efffffffffffffLL ){
+ s2 = (u64)rr[0];
+ rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
+ }else{
rr[1] = 0.0;
}
+ assert( rr[1]<=1.0e-10*rr[0] ); /* Equal only when rr[0]==0.0 */
if( e>0 ){
while( e>=100 ){