Hello people,
Just a quick trivial question:
What is the result of the following code??
I can't fully understand this.Code:#define PP(n) (1 << (n))
I now that defines a new array with 'n' capacity but I can't get the result of the 1<<(n).
Hello people,
Just a quick trivial question:
What is the result of the following code??
I can't fully understand this.Code:#define PP(n) (1 << (n))
I now that defines a new array with 'n' capacity but I can't get the result of the 1<<(n).
It calculates 2**n. (2 to the nth power)
edit - it doesn't "calculate" it, it "defines" it.
Last edited by Dino; 02-05-2008 at 01:39 PM. Reason: clarification
Mainframe assembler programmer by trade. C coder when I can.
1<<0 == 0x0001
1<<1 == 0x0002
1<<16 == 0x0010
etc
it creates the number in binary form of 10000000
where there is n (binary) zeroes after 1
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Bit off there: 1<<16 == 0x100001<<16 == 0x0010
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
I thought so too initially, but he really isn't. Note that he shows 1 << 1 to be 0x0002. It's not the preferred format, but it is not incorrect.
Mainframe assembler programmer by trade. C coder when I can.
He used one digit to represent each byte in a 32 bit word. So, 1<<15 would have been 0x000F.
I've explained it twice - no more sticking up for him!!
Mainframe assembler programmer by trade. C coder when I can.
Yeah, the format he used sucks. I take it back. It's so wrong it's totally unclear. Either that, or or just dipped back into 16 bit harware and showed a 2-byte word.
Mainframe assembler programmer by trade. C coder when I can.
Thank you very much for all the replies!!!
That makes sense now!
Although, I should have tried a bit harder to understand it and not be impatient.