mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
runtime: use dedicated printfloat32
It can be unexpected that printing a float32 involves 64-bit floating point routines, see for example: https://github.com/tinygo-org/tinygo/issues/1415 This commit adds a dedicated printfloat32 instead just for printing float32 values. It comes with a possible code size increase, but only if both float32 and float64 values are printed. Therefore, this should be an improvement in almost all cases. I also tried using printfloat32 for everything (and casting a float64 to float32 to print) but the printed values are slightly different, breaking the testdata/math.go test for example.
This commit is contained in:
committed by
Ron Evans
parent
67de8b490d
commit
431e51b8a0
Vendored
+3
@@ -29,6 +29,9 @@ func main() {
|
||||
// print float64
|
||||
println(3.14)
|
||||
|
||||
// print float32
|
||||
println(float32(3.14))
|
||||
|
||||
// print complex128
|
||||
println(5 + 1.2345i)
|
||||
|
||||
|
||||
Vendored
+1
@@ -16,6 +16,7 @@ a b c
|
||||
123456789012
|
||||
-123456789012
|
||||
+3.140000e+000
|
||||
+3.140000e+000
|
||||
(+5.000000e+000+1.234500e+000i)
|
||||
(0:nil)
|
||||
map[2]
|
||||
|
||||
Reference in New Issue
Block a user