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
Golang program for implementation LIFO Stack and FIFO Queue
Go program to find CNAME record of a domain
Contains, ContainsAny, Count and EqualFold string functions in Go Language
GO Program to Generate Fibonacci Sequence Up to a Certain Number
Modernizing Legacy Applications: Critical Tips for Organizational Upgrades
Golang program to print all Permutations of a given string