Compute the minimum (min) or maximum (max) of two integers without branching?
belongs to collection: Interview questions on bitwise operators in C
All Answers
total answers (1)
belongs to collection: Interview questions on bitwise operators in C
total answers (1)
Answer:
We can find the minimum (min) or maximum (max) number without the branching with the help of a bitwise operator.
Let’s assume “a” and “b” are integers numbers and “result” is another integer variable that contains the result of the
computation.
So to compute the minimum number we have to write the below expression.
need an explanation for this answer? contact us directly to get an explanation for this answer