Last Updated: February 25, 2016
·
524
· ashwin

C: HOW TO FIND ABSOLUTE VALUE OF AN INT WITHOUT USING BRANCHING

int MyAbs(int v){
return v *((v>0)-(v<0));
}

1 Response
Add your response

Is this portable and compliant with all C norms/flavors?

over 1 year ago ·