Help with math functions

Hey there, I’m trying to write this piece of Java code in GO but can’t find solution on Google, could anyone help me?

long r = c ^ (long)(Math.pow(2, Math.ceil(Math.log(c)/Math.log(2))) -1);

The type long maps to int64 or int32. Floats are float64 or float32. The Math functions have corresponding functions in Go’s math package.

Type conversion in Go looks like a function call: int64(math.Log(2)).

And ^ is bitwise XOR, both in Java and Go.



Try this example.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.