I want to implement the sign and flag of zero in a microprocessor. Therefore, I need to write a function to determine if a number is positive, negative, or zero without using if or for loops, and only logical and bitwise operators are allowed . I did the following. But how to implement it for the condition zero ?
int status (int x) { int sign = (x >> 31); return sign; }
Any suggestions?
source share