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
Program in Golang to print Pyramid of Numbers
How to Convert string to integer type in Go?
Golang program for implementation LZW Data Compression and Uncompression
Pass an Interface as an argument to a function in Go (Golang)
Go program to find MX records record of a domain
5 Must-Know Blockchain Trends for 2024 and Beyond