aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/json.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2021-09-26 21:18:24 -0700
committerMike Buland <eichlan@xagasoft.com>2021-09-26 21:18:24 -0700
commit5cda6d3a1622167c5fed35bcd3a02a031ef7a86d (patch)
tree4b9317587209eeedc0610db9d4b94d9e3f4748f7 /src/unstable/json.cpp
parent345926296f748db5ff283ce69c0ed4d563fcc8ff (diff)
downloadlibbu++-5cda6d3a1622167c5fed35bcd3a02a031ef7a86d.tar.gz
libbu++-5cda6d3a1622167c5fed35bcd3a02a031ef7a86d.tar.bz2
libbu++-5cda6d3a1622167c5fed35bcd3a02a031ef7a86d.tar.xz
libbu++-5cda6d3a1622167c5fed35bcd3a02a031ef7a86d.zip
Tweaked number output.
It uses an integer formatting when there is no fractional component to the number, and a fixed point format when there is.
Diffstat (limited to 'src/unstable/json.cpp')
-rw-r--r--src/unstable/json.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp
index 9745a7f..65bd195 100644
--- a/src/unstable/json.cpp
+++ b/src/unstable/json.cpp
@@ -429,7 +429,14 @@ void Bu::Json::write( Bu::Stream &sOutput ) const
429 case Number: 429 case Number:
430 { 430 {
431 char buf[64]; 431 char buf[64];
432 sprintf( buf, "%f", uDat.dNumber ); 432 if( uDat.dNumber == floor( uDat.dNumber ) )
433 {
434 sprintf( buf, "%ld", (int64_t)uDat.dNumber );
435 }
436 else
437 {
438 sprintf( buf, "%f", uDat.dNumber );
439 }
433 sOutput.write( buf ); 440 sOutput.write( buf );
434 } 441 }
435 break; 442 break;