I was given homework to write a program that finds if a double (64 bit) is negative. The double uses twos complement, so the first bit will tell if it is positive (0) or negative (1), but you all probably know that.
The problem I am having is that there can be no floating point operations, just bit masking and shifting. The function can be written with no if statements. It should return 1 if it is negative and 0 if it is not. I thought about masking just the sign bit. I also thought about shifting the sign bit all the way through. Is there any way to just access the first bit and use that in the return statement.
Thanks for any help!