Take the following code snippets that find the absolute value of the variable x.
This one uses logic:
And this one which uses math:Code:
if ( x < 0 )
x *= -1.0f;
Given that the probability of x being negative is equal to the probability of x being positive, which of the two methods is best?Code:
x = fabsf( x );