Posted on 26th March 2023|64 views
How can I convert float type to integer in Golang?
Posted on 26th March 2023
We can convert float type to integer in Golang, but the program you are working on will lose the accuracy of the float. Here is the example of converting float type to integer.
var f float64 = 458.9
var i int = int(f)
fmt.printf(“f = %.2f\n”, f)
fmt.printf(“i = %d\n”, i)
f = 458.90
i = 458
STILL GOT QUERIES?
Copyright © 2013 - 2023 MindMajix Technologies