aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordrh <>2023-07-01 15:23:24 +0000
committerdrh <>2023-07-01 15:23:24 +0000
commit9ee9444a0adbf8f04081447d70d570f17c1a6e6a (patch)
treefa03bf2abe4a0407f771e5c5ff059dc7542a06fc /src/util.c
parent42d042e602233be808084e78ccbaba1b497c69a3 (diff)
downloadsqlite-9ee9444a0adbf8f04081447d70d570f17c1a6e6a.tar.gz
sqlite-9ee9444a0adbf8f04081447d70d570f17c1a6e6a.zip
Improved response to Infinity and NaN. Remove the termporary fpdecode()
function. FossilOrigin-Name: 76ab8ae809a47a66688e2d50c20dc87ce946d82e9ffebb3adda55c451fad07fc
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/util.c b/src/util.c
index a648dc2d1..0950d8427 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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