How to convert a float32 to a float64 in Go

1 Answer

0 votes
package main

import (
    "fmt"
)

func main() {
    var f float32 = 12.34
    d := float64(f)

    fmt.Println("f (float32):", f)
    fmt.Println("d (float64):", d)
}


/*
run:

f (float32): 12.34
d (float64): 12.34000015258789

*/

 



answered Apr 11 by avibootz

Related questions

1 answer 91 views
91 views asked Nov 10, 2024 by avibootz
1 answer 178 views
1 answer 190 views
1 answer 183 views
1 answer 174 views
174 views asked Aug 17, 2020 by avibootz
1 answer 172 views
...