tyInt tyUint fit target int bit width (#20829)

This commit is contained in:
Bung
2022-12-01 20:34:00 +08:00
committed by GitHub
parent a70d3abd37
commit 658b28dc57
17 changed files with 306 additions and 267 deletions

View File

@@ -28,11 +28,11 @@ proc writeFloatToBufferRoundtrip*(buf: var array[65, char]; value: BiggestFloat)
##
## returns the amount of bytes written to `buf` not counting the
## terminating '\0' character.
result = toChars(buf, value, forceTrailingDotZero=true)
result = toChars(buf, value, forceTrailingDotZero=true).int
buf[result] = '\0'
proc writeFloatToBufferRoundtrip*(buf: var array[65, char]; value: float32): int =
result = float32ToChars(buf, value, forceTrailingDotZero=true)
result = float32ToChars(buf, value, forceTrailingDotZero=true).int
buf[result] = '\0'
proc c_sprintf(buf, frmt: cstring): cint {.header: "<stdio.h>",
@@ -49,7 +49,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat):
##
## returns the amount of bytes written to `buf` not counting the
## terminating '\0' character.
var n: int = c_sprintf(cast[cstring](addr buf), "%.16g", value)
var n = c_sprintf(cast[cstring](addr buf), "%.16g", value).int
var hasDot = false
for i in 0..n-1:
if buf[i] == ',':