Correct answer is A & B. My answer was B&C cause when 128 >> 1 is computed, the rule is that whatever the most significant bit is, that has to be "filled" from the left. In this case when 128(10000000) is shifted right by 1 bit, another 1 will be added cause initially the most significant bit of 128 was 1. This will give us 11000000 which comes out to be 192. Am i correct??
Thanks Faqeer
Jan Valenta
Ranch Hand
Joined: Nov 30, 2005
Posts: 32
posted
0
Don't forget that there is automatic promotion of the operands to ints. Therefore you are shifting (00000000 00000000 00000000 10000000) and the initial zero stays zero.
Jan
Anybody knows about a job for <a href="http://cern.ch/jvalenta/valenta-cv.pdf" target="_blank" rel="nofollow">SCJP5.0, Ph.D. in Software Engineering, 2 years Java, C, C++</a> in Montreal, QC, Canada? Thanks!
128 value is 00000000 00000000 00000000 10000000 based on the referred link above
>> 00000000 00000000 00000000 01000000 (fills with highest (sign) bit on the left side ) >>> 00000000 00000000 00000000 01000000 (fills with 0 bits on the left side )
Parallax - Change in observational position that provides a new line of sight.
Faqeer Khudaka
Ranch Hand
Joined: Jan 24, 2006
Posts: 32
posted
0
Thanks guys. I didnt pay attention to the int promotion thing.
Bert Bates
author
Sheriff
Joined: Oct 14, 2002
Posts: 8712
posted
0
remember this topic is on the 1.4 exam, but it's NOT on the 1.5 exam.
Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)