How to explicit conversion from int to float64 and from float64 to uint in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b int = 12, 7
	var f float64 = math.Sqrt(float64(a * b))
	var ui uint = uint(f)
	fmt.Println(a, b, f, ui)
}



/*
run:

12 7 9.16515138991168 9

*/

 



answered Feb 29, 2020 by avibootz

Related questions

...