added float32 schubfach algorithm; wip (#18155)

* added float32 schubfach algorithm; wip

* fixes #18418
This commit is contained in:
Andreas Rumpf 2021-06-03 12:09:40 +02:00 • committed by GitHub
commit daaa40973c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 478 additions and 1 deletions

View file

@ -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.}