Posts: 566
Threads: 86
Joined: Feb 2003
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 ?
hink Global, Make Symp' All ! ®
Posts: 273
Threads: 51
Joined: May 2002
hmmm, I've never seen that syntax. Perhaps it's a typo. It probably means:
n=(n<13)^n
which means n=n^n if n < 13
But I also don't know too much C, so I could be wrong.
Posts: 566
Threads: 86
Joined: Feb 2003
The line comes from Hugo Elias webpage. It was copied and copied on other pages, and the syntax is always the same...
hink Global, Make Symp' All ! ®
Posts: 3,368
Threads: 195
Joined: Jan 2003
Coming from nathan's reply in the challenge forum, it should be:
2^n^13^n......
My C++ book says it is a bitwise left shift...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 566
Threads: 86
Joined: Feb 2003
Thanks Aga, I'm gonna try to apply that... It's included in a random number generator.
hink Global, Make Symp' All ! ®
Posts: 3,368
Threads: 195
Joined: Jan 2003
I'm not sure how exactly to translate it, though......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,407
Threads: 117
Joined: Dec 2002
Hugo Elias uses to put pseudocode at his page, not any known language...
Antoni
Posts: 1,080
Threads: 87
Joined: Feb 2002
you can use "<<" and ">>" in c++ afaik but I don't know what they
do...
/post]
Posts: 269
Threads: 44
Joined: Oct 2002
I think it is for shifting bytes as it was said above. Although byte shifting is somthing I really should look more into....along with linked lists....
Posts: 1,752
Threads: 21
Joined: Jun 2002
Yes, it's a bit shift...
Code:
n = (n * 2^13) ^ n
n = (n * 8192) ^ n