Half an integer without using * or / in your preferred language.
Interview Answers
Anonymous
Oct 3, 2017
So I guess you could bit shift it by 1 to get half the result
n >> 1
1
Anonymous
Jan 8, 2018
float half = number & 0x1? number>>1+.5f : number>>1
Anonymous
Jul 7, 2018
Well this was a long time ago, but for those who still interested :
Just a one bit right shifting the integer would give you the half of it
Assuming we have a number : int n = 150;
Half will be equal to :
float half = (n >> 1) + 0.5f;
Happy coding!