std/formatfloat (original) (raw)

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 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 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