shift operator << and >> question...

P

Peter Lee

ASSUME unsigned int = 32 bits

#q1 unsigned int u1 = 3u << 0u valid?
#q2 unsigned int u2 = 3u >> 0u valid?
#q3 unsigned int u3 = 3u << 32u valid?
#q4 unsigned int u4 = 3u >> 32u valid?
 
P

peter koch

ASSUME unsigned int = 32 bits

#q1 unsigned int u1 = 3u << 0u valid?
#q2 unsigned int u2 = 3u >> 0u valid? Yes
#q3 unsigned int u3 = 3u << 32u valid?
#q4 unsigned int u4 = 3u >> 32u valid?
No - you are only allowed to shift less than the bits in the type. So
the max is 31 in your case.

/Peter
 
R

Rolf Magnus

Peter said:
ASSUME unsigned int = 32 bits

#q1 unsigned int u1 = 3u << 0u valid?
yes

#q2 unsigned int u2 = 3u >> 0u valid?
yes

#q3 unsigned int u3 = 3u << 32u valid?
no

#q4 unsigned int u4 = 3u >> 32u valid?

no
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top