Asked • 06/27/19

Determine the sign of a 32 bit int?

Using ONLY: ! ~ & ^ | + << >> NO LOOPS I need to determine the sign of a 32 bit integer and I need to return 1 if positive, 0 if 0 and -1 if negative. Any ideas? I first thought about shifting over 31 bits and then looking at that sign but that obviously wont work and now I am kind of stuck.

2 Answers By Expert Tutors


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.