added float32 schubfach algorithm; wip (#18155)
* added float32 schubfach algorithm; wip * fixes #18418
This commit is contained in:
parent
06960bb9cb
commit
daaa40973c
5 changed files with 478 additions and 1 deletions
|
|
@ -164,6 +164,19 @@ proc nimFloatToStr(f: float): string {.compilerproc.} =
|
|||
result = newStringOfCap(8)
|
||||
result.addFloat f
|
||||
|
||||
when not defined(nimLegacyAddFloat) and not defined(nimscript) and
|
||||
not defined(js) and defined(nimHasDragonBox):
|
||||
import schubfach
|
||||
|
||||
proc nimFloat32ToStr(f: float32): string {.compilerproc.} =
|
||||
when declared(float32ToChars):
|
||||
result = newString(65)
|
||||
let L = float32ToChars(result, f, forceTrailingDotZero=true)
|
||||
setLen(result, L)
|
||||
else:
|
||||
result = newStringOfCap(8)
|
||||
result.addFloat f
|
||||
|
||||
proc c_strtod(buf: cstring, endptr: ptr cstring): float64 {.
|
||||
importc: "strtod", header: "<stdlib.h>", noSideEffect.}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue