Go: Convert float to int
When converting a floating-point number to an
the fraction is discarded (truncation towards zero):
var f float64 = 1.9 n := int64(f) // 1 n = int64(-f) // -1
Warning: If the result type cannot represent the value the conversion succeeds but the result value is implementation-dependent.
Be the first to comment!