Convert Float32 to Float64 and Float64 to Float32
Example
package main
import (
"fmt"
"reflect"
)
func main() {
var f32 float32 = 10.6556
fmt.Println(reflect.TypeOf(f32))
f64 := float64(f32)
fmt.Println(reflect.TypeOf(f64))
f64 = 1097.655698798798
fmt.Println(f64)
f32 = float32(f64)
fmt.Println(f32)
}
Output
float32
float64
1097.655698798798
1097.6556
Most Helpful This Week
How to build a map of struct and append values to it?
Golang program to print a matrix in Spiral Format
Avoid Unintended Variable Shadowing in Golang
How do you handle HTTP server health checks in Go?
Defining a type that satisfies an interface in Go Programming Language
Illustration of Producer Consumer Problem in Golang