Raised This Month: $51 Target: $400
 12% 

[Solved] Bitwise Left Shift


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-06-2014 , 01:03   [Solved] Bitwise Left Shift
Reply With Quote #1

Can anyone explain the result of this expression with proper bit pattern
Code:
1<<24
__________________

Last edited by ezio_auditore; 05-06-2014 at 06:31.
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2014 , 01:08   Re: [HELP] Bitwise Left Shift
Reply With Quote #2

It's a 1 shifted left 24 positions . . . What else is there to know?
__________________
fysiks is offline
felipemilralze
Senior Member
Join Date: Jul 2011
Location: Brazil
Old 05-06-2014 , 03:44   Re: [HELP] Bitwise Left Shift
Reply With Quote #3

for example

8<<1 // 16 = 8*2 or 8+8
8>>1 // 4 = 8/2 or 8-4

I do not understand it 1<<24.

I do not know but it will result in a high value because 24 positions left.

Last edited by felipemilralze; 05-06-2014 at 03:57.
felipemilralze is offline
Send a message via MSN to felipemilralze Send a message via Skype™ to felipemilralze
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-06-2014 , 04:29   Re: [HELP] Bitwise Left Shift
Reply With Quote #4

1<<24 = 2^24. The value also depends on the size of the variable its assigned to.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-06-2014 , 04:54   Re: [HELP] Bitwise Left Shift
Reply With Quote #5

for example....
2|3 returns into 3.
The bit-pattern of 2 is 0010 and that of 3 is 0011...
we have.
0010 |
0011
------
0011.
which is three
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-06-2014 , 05:06   Re: [HELP] Bitwise Left Shift
Reply With Quote #6

for example....
1<<3 gives 8.
The bit pattern of 1 is 0001.

Shifting 1 to three positions left,
1<<3 gives
1000
which is 8.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-06-2014 , 05:31   Re: [HELP] Bitwise Left Shift
Reply With Quote #7

ahhh...
then this should be a large number...
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2014 , 05:39   Re: [HELP] Bitwise Left Shift
Reply With Quote #8

Quote:
Originally Posted by ezio_auditore View Post
for example....
2|3 returns into 3.
The bit-pattern of 2 is 0010 and that of 3 is 0011...
we have.
0010 |
0011
------
0011.
which is three
None of that has anything to do with anything said in this thread.

Quote:
Originally Posted by ezio_auditore View Post
ahhh...
then this should be a large number...
That doesn't make sense. You should tell us what you are actually trying to do if you want good advice.
__________________
fysiks is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-06-2014 , 06:28   Re: [HELP] Bitwise Left Shift
Reply With Quote #9

I wanted to explain it with a proper bit pattern.
the expression 1<<24 results into 16777216.
since the bit pattern of 1 is:
0000 0000 0000 0000 0000 0000 0000 0001.
Then we move it 24 bits left which results into:
0000 0001 0000 0000 0000 0000 0000 0000.
which is the bit pattern of 16777216.
Problem Solved
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode