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
GO Program to take user input and addition of two strings
Web Application to generate QR code in Golang
How do you create an HTTP server in Go?
How to get first and last element of slice in Golang?
Top Programming Languages Behind Blockchain App Development
GO Program to Find Factorial of a Number
How To Make HTTP Requests in Go?
Example: How to use ReadAtLeast from IO Package in Golang?
How do you handle HTTP server caching in Go?
Creating a Struct Instance Using a Struct Literal