std/formatfloat

Source   Edit  

This module implements formatting floats as strings.

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"
Source   Edit  
proc addFloatRoundtrip(result: var string; x: float | float32)
Source   Edit  
proc addFloatSprintf(result: var string; x: float) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc writeFloatToBuffer(buf: var array[65, char]; value: BiggestFloat | float32): int {.
    inline.}
Source   Edit  
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.

Source   Edit  
proc writeFloatToBufferRoundtrip(buf: var array[65, char]; value: float32): int {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
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.

Source   Edit