Monday, March 28, 2011

Find the absolute value of an integer

Given an integer find the absolute value without using conditional statements

The last bit (31st bit in case of 4 byte variable) contains the sign information. If you update the value of the 31st bit, the job is done.