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
Regular expression to extract domain from URL
Regular expression to extract filename from given path in Golang
User Defined Function Types in Golang
Golang Slice vs Map Benchmark Testing
Example: Split, Join, and Equal from BYTES Package
How to convert Boolean Type to String in Go?
How can we reverse a simple string in Go?
Example to create custom error
How to Draw a rectangle in Golang?
Various examples of printing and formatting in Golang