Littlefoot: Arithmetic Operator ^ Doesn't Work

There seems to be an issue with the ^ arithmetic operator in Littlefoot. It should raise a value to a power, but it appears to only add.

For example if I do this:
int val = 4 ^ 2;
log(val);

The console shows 6, not 16.

The same thing happens with floats:

float val = 4.0 ^ 2.0;
log(int(val)); //Have to cast as an int as you can’t log a float.

The console once again shows 6.

^ is the XOR operator in most C-like languages. You’re looking for the pow function maybe?

1 Like

Oops. You are right. I’ve gotten too used to my graphing calculator. Thank you for pointing that out.

Unfortunately pow() and sqrt() don’t appear to be implemented.

I was hoping to be able to calculate distances between touches on the Lightpad Block using the Pythagorean Theorem.