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?
How to read names of all files and folders in current directory?
Split a string at uppercase letters using regular expression in Golang
Example of Fscan, Fscanf, and Fscanln from FMT Package
How to get current IP form ipify.org ?
How to check if a string contains certain characters in Golang?