aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-03-17 20:31:24 +0000
committerdrh <>2023-03-17 20:31:24 +0000
commit667b5cc985d68f0f63e67a2888d0ec36c83a1688 (patch)
treededadd04730861ccd0ff89187756aceeedb7d2c5 /src
parentf204be8098faa2182822baf748908da4371cad8d (diff)
downloadsqlite-667b5cc985d68f0f63e67a2888d0ec36c83a1688.tar.gz
sqlite-667b5cc985d68f0f63e67a2888d0ec36c83a1688.zip
Fix json rendering so that it shows positive and negative infinity as
9.0e+999 and -9.0e+999 respectively. FossilOrigin-Name: efce4690a52592c4f5fc7d023eebe771b0e615bb03c0fe203493f853b28e8f85
Diffstat (limited to 'src')
-rw-r--r--src/json.c5
-rw-r--r--src/printf.c15
2 files changed, 14 insertions, 6 deletions
diff --git a/src/json.c b/src/json.c
index 67448421b..9783a3898 100644
--- a/src/json.c
+++ b/src/json.c
@@ -307,8 +307,11 @@ static void jsonAppendValue(
jsonAppendRaw(p, "null", 4);
break;
}
- case SQLITE_INTEGER:
case SQLITE_FLOAT: {
+ jsonPrintf(100, p, "%!0.15g", sqlite3_value_double(pValue));
+ break;
+ }
+ case SQLITE_INTEGER: {
const char *z = (const char*)sqlite3_value_text(pValue);
u32 n = (u32)sqlite3_value_bytes(pValue);
jsonAppendRaw(p, z, n);
diff --git a/src/printf.c b/src/printf.c
index b222cb214..d59855917 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -601,11 +601,16 @@ void sqlite3_str_vappendf(
while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }
while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }
if( exp>350 ){
- bufpt = buf;
- buf[0] = prefix;
- memcpy(buf+(prefix!=0),"Inf",4);
- length = 3+(prefix!=0);
- break;
+ if( flag_zeropad ){
+ realvalue = 9.0;
+ exp = 999;
+ }else{
+ bufpt = buf;
+ buf[0] = prefix;
+ memcpy(buf+(prefix!=0),"Inf",4);
+ length = 3+(prefix!=0);
+ break;
+ }
}
if( xtype!=etFLOAT ){
realvalue += rounder;