Answers for "C bitwise integer absolute value"

C
2

C bitwise integer absolute value

// Absolute value for integers
int a = -4268;
// mask = a >> 31 -> (mask ^ a) - mask
int abs = ((a >> 31) ^ a) - (a >> 31);
Posted by: Guest on January-07-2021

Code answers related to "C"

Browse Popular Code Answers by Language