C: HOW TO FIND ABSOLUTE VALUE OF AN INT WITHOUT USING BRANCHING
int MyAbs(int v){
return v *((v>0)-(v<0));
}
Written by Ashwin R Sidhalinganahalli
Related protips
1 Response
Is this portable and compliant with all C norms/flavors?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#C
Authors
Related Tags
#c
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#