I\'m reading the recently released The Go Programming Language, and it\'s been a joy so far (with Brian Kernighan being one of the authors, I wouldn\'t expect anything other
I would say that this is impossible because what you want is to represent a function 10^(3i)
where i
is a positive integer as some function f(i)
, where f
is a compositive function of your elementary go functions (+, -, /, *).
It was possible for 2^(10i)
only because go introduced another elementary function integer exponentiation. So if 1 << y
would allow y being float, you would be able to modify your code to use 1 << (log2(10) * 3 * i)
. This would worked because this is equivalent to solving 10^(3i) = 2^y
. Taking log2 of both sides y = log2(10) * 3 * i
.
But sadly enough bitwise shift is an integer operation.