summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-02-08 00:30:24 -0800
committerGitHub <noreply@github.com>2020-02-08 09:30:24 +0100
commite4415422fe2b615a6dfe01bb7136ec41ef429108 (patch)
tree8e9f45c193aad54fa60c79cdc8e5f1981cea04cf /lib
parentf3117d350ea245769d60a80b2d12b062cff4b8ff (diff)
downloadNim-e4415422fe2b615a6dfe01bb7136ec41ef429108.tar.gz
Revert "printing float values will have one more digit. (#13276) [backport]" (#13363)
This reverts commit b2c6db97f9f477f6999fa9c7aae5e32f10b6b3fe.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/json.nim4
-rw-r--r--lib/system/formatfloat.nim2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 6ec0d1616..319a7b7ff 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -677,7 +677,7 @@ proc pretty*(node: JsonNode, indent = 2): string =
   ## Similar to prettyprint in Python.
   runnableExamples:
     let j = %* {"name": "Isaac", "books": ["Robot Dreams"],
-                "details": {"age": 35, "number": 3.125}}
+                "details": {"age": 35, "pi": 3.1415}}
     doAssert pretty(j) == """
 {
   "name": "Isaac",
@@ -686,7 +686,7 @@ proc pretty*(node: JsonNode, indent = 2): string =
   ],
   "details": {
     "age": 35,
-    "number": 3.125
+    "pi": 3.1415
   }
 }"""
   result = ""
diff --git a/lib/system/formatfloat.nim b/lib/system/formatfloat.nim
index abacca4df..cb46c8c36 100644
--- a/lib/system/formatfloat.nim
+++ b/lib/system/formatfloat.nim
@@ -29,7 +29,7 @@ proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat): int =
   ## * `buf` - A buffer to write into. The buffer does not need to be
   ##           initialized and it will be overridden.
   ##
-  var n: int = c_sprintf(addr buf, "%.17g", value)
+  var n: int = c_sprintf(addr buf, "%.16g", value)
   var hasDot = false
   for i in 0..n-1:
     if buf[i] == ',':