Quote:I found this line of code while working on Perlin noise:
n = (n<<13) ^ n
It's C, I guess, and I can't guess how to translate that into Basic...
Can anybody help ?
jark...if it's c++ then "^" is the bitwise XOR, not "to the power of".
As such, I read:
// c++ code
n = (n<<13) ^ n;
// end of c++
as equivalent to:
' QB4.5 code
n = (n * (2 ^ 13)) XOR n
' end of QB code
cheers.
c++ makes goofy use of symbols where the same symbol has different meanings, depending on context.
Here's a basic rundown:
+, -. /, *.....as expected...usually
! NOT (bitwise or logical)
& AND (bitwise) unless it is in front of a variable, in which case it means "return the address of this variable"
&& AND (logical)
| OR (bitwise)
|| OR (logical)
^ XOR (bitwise)
% MOD
<, >, <=, <= (logical evaluators)
<<, >> (bitshift operators)
<< overloaded class inserter eg cout << "Hello world"; is equivalent to the Basic PRINT "Hello world"
>> overloaded extractor eg cin << x; is equivalent to the Basic INPUT x
= assignment
== logical equivalence evaluator
but then...you have to be on the lookout for other uses...for example, is one form of the "points to" operator, not "minus minus greater than" ;-)