Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does this line mean ?
#1
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 ! ®
[Image: Banner.gif]
Reply
#2
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.
Reply
#3
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 ! ®
[Image: Banner.gif]
Reply
#4
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.
Reply
#5
Thanks Aga, I'm gonna try to apply that... It's included in a random number generator.
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#6
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.
Reply
#7
Hugo Elias uses to put pseudocode at his page, not any known language...
Antoni
Reply
#8
you can use "<<" and ">>" in c++ afaik but I don't know what they
do...
/post]
Reply
#9
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....
Reply
#10
Yes, it's a bit shift...

Code:
n = (n * 2^13) ^ n
n = (n * 8192) ^ n
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)