A short way to make sure that they are equal is to store the value of the number raised to a power in a variable.
=======
FOR j = 1 TO 20
variab = j ^ 2
IF (variab) <> (j * j) THEN PRINT j; 'nothing should be PRINTed
NEXT j
=======
This works because the value is calculated before comparison. The original statement that the exponentiation operator (^) doesn't work properly in IF statements is still true however. To prove this, here is a program that will show the values:
=======
PRINT "j", "j ^ 2", "j * j"
FOR j = 1 TO 20
PRINT j, j ^ 2, j * j
NEXT j
=======
This proves that j^2 and j*j are equal to each other in the end. |