I would like an efficient way to get the positive value of a double.
The obvious way would be:
but I would like something which is faster. I have considered the fact of using a mask on the number (so its first bit - the sign bit according to the IEEE 754 standard - would become 0) but that simply doesn't work on double number. The & doesn't work at all on double numbers.Code:
double absolute(double number)
if (number < 0)