Question : Go int to float conversion
Answered by : samer-saeid
package main
import "fmt"
func main() { var intValue int = 2 // type conversion from int to float var floatValue float32 = float32(intValue) fmt.Printf("Integer Value is %d\n", intValue) fmt.Printf("Float Value is %f", floatValue)
}
Source : | Last Update : Thu, 23 Jun 22
Question : Go float to int conversion
Answered by : samer-saeid
package main
import "fmt"
func main() { var floatValue float32 = 5.45 // type conversion from float to int var intValue int = int(floatValue) fmt.Printf("Float Value is %g\n", floatValue) fmt.Printf("Integer Value is %d", intValue)
}
Source : | Last Update : Thu, 23 Jun 22