1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Improved accuracy of floating-point conversion constants as suggested by

[forum:/info/598d32f6135c41c1|forum post 598d32f6135c41c1].

FossilOrigin-Name: 4943e8a1819e189747eefc414d02c0485e1620deff9cf92664295b21a8a9a83c
This commit is contained in:
drh
2023-06-28 11:46:28 +00:00
parent 502c618f01
commit 60783f47b2
4 changed files with 19 additions and 19 deletions

View File

@@ -468,7 +468,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
int esign = 1; /* sign of exponent */
int e = 0; /* exponent */
int eValid = 1; /* True exponent is either not used or is well-formed */
double result;
LONGDOUBLE_TYPE result;
int nDigit = 0; /* Number of digits processed */
int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
@@ -597,7 +597,7 @@ do_atof_calc:
s = sign<0 ? -s : s;
if( e==0 ){ /*OPTIMIZATION-IF-TRUE*/
result = (double)s;
result = (LONGDOUBLE_TYPE)s;
}else{
/* attempt to handle extremely small/large numbers better */
if( e>307 ){ /*OPTIMIZATION-IF-TRUE*/
@@ -605,10 +605,10 @@ do_atof_calc:
LONGDOUBLE_TYPE scale = sqlite3Pow10(e-308);
if( esign<0 ){
result = s / scale;
result /= 1.0e+308;
result /= 1.0e+308L;
}else{
result = s * scale;
result *= 1.0e+308;
result *= 1.0e+308L;
}
}else{ assert( e>=342 );
if( esign<0 ){