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

Improved response to Infinity and NaN. Remove the termporary fpdecode()

function.

FossilOrigin-Name: 76ab8ae809a47a66688e2d50c20dc87ce946d82e9ffebb3adda55c451fad07fc
This commit is contained in:
drh
2023-07-01 15:23:24 +00:00
parent 42d042e602
commit 9ee9444a0a
6 changed files with 43 additions and 79 deletions

View File

@@ -941,6 +941,7 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound){
int i;
u64 v;
int e, exp = 0;
p->isSpecial = 0;
if( r<0.0 ){
p->sign = '-';
r = -r;
@@ -949,8 +950,6 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound){
p->n = 1;
p->iDP = 1;
p->z[0] = '0';
p->isNan = 0;
p->isInf = 0;
return;
}else{
p->sign = '+';
@@ -958,24 +957,11 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound){
memcpy(&v,&r,8);
e = v>>52;
if( (e&0x7ff)==0x7ff ){
if( v==0x7ff0000000000000L ){
p->isInf = 1;
p->isNan = 0;
p->z[0] = 'I';
p->z[1] = 'n';
p->z[2] = 'f';
}else{
p->isInf = 0;
p->isNan = 1;
p->z[0] = 'N';
p->z[1] = 'a';
p->z[2] = 'N';
}
p->n = 3;
p->iDP = 3;
p->isSpecial = 1 + (v!=0x7ff0000000000000L);
p->n = 0;
p->iDP = 0;
return;
}
p->isNan = p->isInf = 0;
/* At this point, r is positive (non-zero) and is not Inf or NaN.
** The strategy is to multiple or divide r by powers of 10 until