consistent floating point output (#12219)
* unify float printing * makes tests green
This commit is contained in:
parent
04c803d6df
commit
7bc5bf8334
4 changed files with 81 additions and 34 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#
|
||||
|
||||
include inclrtl
|
||||
import formatfloat
|
||||
|
||||
# ----------------- IO Part ------------------------------------------------
|
||||
type
|
||||
|
|
@ -350,10 +351,16 @@ proc write*(f: File, i: BiggestInt) {.tags: [WriteIOEffect], benign.} =
|
|||
proc write*(f: File, b: bool) {.tags: [WriteIOEffect], benign.} =
|
||||
if b: write(f, "true")
|
||||
else: write(f, "false")
|
||||
|
||||
proc write*(f: File, r: float32) {.tags: [WriteIOEffect], benign.} =
|
||||
if c_fprintf(f, "%.16g", r) < 0: checkErr(f)
|
||||
var buffer: array[65, char]
|
||||
discard writeFloatToBuffer(buffer, r)
|
||||
if c_fprintf(f, "%s", buffer[0].addr) < 0: checkErr(f)
|
||||
|
||||
proc write*(f: File, r: BiggestFloat) {.tags: [WriteIOEffect], benign.} =
|
||||
if c_fprintf(f, "%.16g", r) < 0: checkErr(f)
|
||||
var buffer: array[65, char]
|
||||
discard writeFloatToBuffer(buffer, r)
|
||||
if c_fprintf(f, "%s", buffer[0].addr) < 0: checkErr(f)
|
||||
|
||||
proc write*(f: File, c: char) {.tags: [WriteIOEffect], benign.} =
|
||||
discard c_putc(cint(c), f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue