Determining the sign of an int using shifts?
Here's the question
sign - return 1 if positive, 0 if zero, and -1 if negative
Legal ops: ! ~ & ^ | + << >>
Max ops: 10
Rating: 2
I thought of shifting to the left by 31 to grab the sign bit but can't 0
be positive AND negative technically?
No comments:
Post a Comment