mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Improved rounding even on systems with an 8-byte "long double" type.
FossilOrigin-Name: 15202aee150fa8e15fb90e90e5765c5e19a1eaf4896da2996a747636b76da8e6
This commit is contained in:
@@ -527,7 +527,12 @@ void sqlite3_str_vappendf(
|
||||
rounder = arRound[idx%10];
|
||||
while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; }
|
||||
if( xtype==etFLOAT ){
|
||||
if( precision<17) rounder += realvalue*2.0e-16;
|
||||
double rx = (double)realvalue;
|
||||
sqlite3_uint64 u;
|
||||
int ex;
|
||||
memcpy(&u, &rx, sizeof(u));
|
||||
ex = -1023 + (int)((u>>52)&0x7ff);
|
||||
if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16;
|
||||
realvalue += rounder;
|
||||
}
|
||||
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
|
||||
|
||||
Reference in New Issue
Block a user