> I'm getting this error:
>
> Cannot use -a (type int) as type float64 in function argument
> var (
> a = 53
> b = math.Pow(2, -a)
> )
> var (
> b = math.Pow(2, -53)
> )
This is correct. You didn't declare a type for a, and the initializer
is integral, so it gets the type "int". Pasisng a variable of type int
to a function which expects a value of type float64 requires a type
conversion.
In the second case, you are passing a constant. Constants are untyped
by default, and may be assigned to a value of any type which can
represent the constant.
This code would work if you changed a from a var to a const.
Ian