]> Cypherpunks repositories - gostls13.git/commit
cmd/compile,runtime: implement uint64->float32 correctly on 32-bit archs
authorKeith Randall <khr@golang.org>
Wed, 6 Oct 2021 21:53:32 +0000 (14:53 -0700)
committerKeith Randall <khr@golang.org>
Thu, 7 Oct 2021 18:34:24 +0000 (18:34 +0000)
commit2043b3b47b3ca76d8ce44f05a77e48d2291b6fc6
treef79c8afe98db2f4ec23f2a332abfdb23b8528b8b
parent4607ebc7d897c36687ae4ede3cfd4939c6dd0a54
cmd/compile,runtime: implement uint64->float32 correctly on 32-bit archs

The old way of implementing it, float32(float64(x)), involves 2 roundings
which can cause accuracy errors in some strange cases. Implement a runtime
version of [u]int64tofloat32 which only does one rounding.

Fixes #48807

Change-Id: Ie580be480bee4f3a479e58ef8dce23032f231704
Reviewed-on: https://go-review.googlesource.com/c/go/+/354429
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/typecheck/builtin.go
src/cmd/compile/internal/typecheck/builtin/runtime.go
src/cmd/compile/internal/walk/convert.go
src/runtime/float_test.go [new file with mode: 0644]
src/runtime/vlrt.go