Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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);
 
PREVIOUS NEXT
Tagged: #C #bitwise #integer #absolute
ADD COMMENT
Topic
Name
6+1 =