- Thanks received
- 0
Had a tech test today which was in the main ok. One question though did my head in, I was asked something like:
int i = 500;
i = i << 4;
Tell us what i is.
What the hell is the << operator, its probably something dead obvious but I seem to have gone through my career without using << ?
I never used this in real life.
--
int i = 500;
Console.WriteLine("Base2: "+ Convert.ToString(i, 2));
i = i << 4;
Console.WriteLine("Base2: " + Convert.ToString(i, 2));
Console.WriteLine("Decimal: " + i);
--
It outputs:
--
Base2: 111110100
Base2: 1111101000000
Decimal: 8000
--
C# Bitwise Shift Operators
Had a tech test today which was in the main ok. One question though did my head in, I was asked something like:
int i = 500;
i = i << 4;
Tell us what i is.
What the hell is the << operator, its probably something dead obvious but I seem to have gone through my career without using << ?
Anyone got a real world example where it would be useful?
Sounds like the sort of meaningless trick question technical interviewers only ever ask when they want to feel clever, or that they think will impress their non-technical boss that is also on the interview panel.
Dunno, but they are twats for putting that in an interview, fair threw me off my stride it did.
Googling about, it seems more associated with very low level development which as a VB/C#'er I dont touch. Do we have any Level 75 Dark Mages in the house?