Converting Int data type to Float in Go
Example
package main
import (
"fmt"
"reflect"
)
func main() {
var f32 float32 = 10.6556
fmt.Println(reflect.TypeOf(f32))
i32 := int32(f32)
fmt.Println(reflect.TypeOf(i32))
fmt.Println(i32)
f64 := float64(i32)
fmt.Println(reflect.TypeOf(f64))
}
Output
float32
int32
10
float64
Most Helpful This Week
How to create Map using the make function in Go?
Golang download image from given URL
Different ways to convert Byte Array into String
What is Rune? How to get ASCII value of any character in Go?
How to compare equality of struct, slice and map?
How to use wildcard or a variable in our URL for complex routing?