C# Programming - Operators - Discussion
Discussion Forum : Operators - General Questions (Q.No. 13)
13.
What will be the output of the C#.NET code snippet given below?
byte b1 = 0xAB;
byte b2 = 0x99;
byte temp;
temp = (byte)~b2;
Console.Write(temp + " ");
temp = (byte)(b1 << b2);
Console.Write (temp + " ");
temp = (byte) (b2 >> 2);
Console.WriteLine(temp);
Discussion:
10 comments Page 1 of 1.
HanLin said:
7 years ago
'0x' represents the hexadecimal number.
Anshul jain said:
10 years ago
Please someone tell me b1 << b2.
Who work?
Who work?
Anshul said:
10 years ago
How convert binary into decimal? Explain any one?
Abhishek yadav said:
1 decade ago
What is the meaning of Ox in Ox99?
Sudeep suman said:
1 decade ago
~ means compliment that means if value is =0 then it will be 1 and vice versa.
Nidhi said:
1 decade ago
What doesn't "~" do?
Usha said:
1 decade ago
Please tel me how to left shift or right shift.
Rajeev said:
1 decade ago
b1 << b2 --> b1 is left shifted b2 times, causes byte overflow. So temp = 0
b2 >> 2 --> right shift by 2 and padded with 0
b2(153)10011001 --> 00100110 - 38
b2 >> 2 --> right shift by 2 and padded with 0
b2(153)10011001 --> 00100110 - 38
Jitender said:
1 decade ago
First convert 0x99 into decimal it is 153 and after that convert 153 into binary and it is 1011001. We take difference for compliment operator.
And 255-153=102 which is required for first temp.
And 255-153=102 which is required for first temp.
Subramanyam said:
1 decade ago
Please give me answer for this Question.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers