You must first convert the types to float.
In general, if you have some non-floating numeric types (for example, int s) a and b , to get float division you use float32(a)/ float32(b) (or float64 as it may be). This applies to any other digital type if you want to treat float as integers or integers, since complex numbers convert operands. In this case, if a is 3 and b is 2, float32(a)/float32(b) will be 1.5.
If you want integer division to be performed, but the result is float, then the hidden result is, as in float32(a/b) . In this case, if a is 3 and b is 2, then float32(a/b) will get 1.0.
LinearZoetrope
source share