This module implements formatting floats as strings.
Imports
Procs
proc addFloat(result: var string; x: float | float32) {.inline.}
Converts float to its string representation and appends it to result.
Example:
var
s = "foo:"
b = 45.67
s.addFloat(45.67)
assert s == "foo:45.67"
proc addFloatRoundtrip(result: var string; x: float | float32)
proc addFloatSprintf(result: var string; x: float) {....raises: [], tags: [],
forbids: [].}
proc writeFloatToBuffer(buf: var array[65, char]; value: BiggestFloat | float32): int {.
inline.}
proc writeFloatToBufferRoundtrip(buf: var array[65, char]; value: BiggestFloat): int {.
...raises: [], tags: [], forbids: [].}
This is the implementation to format floats.
returns the amount of bytes written to buf not counting the terminating ‘0’ character.
proc writeFloatToBufferRoundtrip(buf: var array[65, char]; value: float32): int {.
...raises: [], tags: [], forbids: [].}
proc writeFloatToBufferSprintf(buf: var array[65, char]; value: BiggestFloat): int {.
...raises: [], tags: [], forbids: [].}
This is the implementation to format floats.
returns the amount of bytes written to buf not counting the terminating ‘0’ character.