Answers for "Go convert float to a string"

Go
2

Go convert float to a string

s := fmt.Sprintf("%f", 123.456) // s == "123.456000"
Posted by: Guest on January-02-2020
0

Go convert float to a string

// ...
v := 3.1415926535

s32 := strconv.FormatFloat(v, 'E', -1, 32)
fmt.Printf("%T, %v\n", s32, s32)

s64 := strconv.FormatFloat(v, 'E', -1, 64)
fmt.Printf("%T, %v\n", s64, s64)
// ...
Posted by: Guest on April-30-2021

Code answers related to "Go convert float to a string"

Browse Popular Code Answers by Language