Source Edit

This module implements formatting floats as strings.

Imports

dragonbox, schubfach

Procs

  1. proc addFloat(result: var string; x: float | float32) {.inline.}

Converts float to its string representation and appends it to result.

Example:

  1. var
  2. s = "foo:"
  3. b = 45.67
  4. s.addFloat(45.67)
  5. assert s == "foo:45.67"

Source Edit

  1. proc addFloatRoundtrip(result: var string; x: float | float32)

Source Edit

  1. proc addFloatSprintf(result: var string; x: float) {....raises: [], tags: [],
  2. forbids: [].}

Source Edit

  1. proc writeFloatToBuffer(buf: var array[65, char]; value: BiggestFloat | float32): int {.
  2. inline.}

Source Edit

  1. proc writeFloatToBufferRoundtrip(buf: var array[65, char]; value: BiggestFloat): int {.
  2. ...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

  1. proc writeFloatToBufferRoundtrip(buf: var array[65, char]; value: float32): int {.
  2. ...raises: [], tags: [], forbids: [].}

Source Edit

  1. proc writeFloatToBufferSprintf(buf: var array[65, char]; value: BiggestFloat): int {.
  2. ...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