Negative Number « bit « Java Data Type Q&A

1. How to determine if a number is positive or negative in Java?

I was asked this question in Amazon Chennai(India) interview , to determine whether an number is positive or negative. The rules are that , we should not use conditional operators such ...

2. Negative numbers shown in bits

Okay.. so here's an easy one for you. How can I represent -4 in bits. Any good rule of thumb would be great so its easy to remember how to do it later. I understand the positive 4. Thats easy. 0100 Thanks -Dale ------------------ What's this H2SO4 doing in my fridge?? ( thud )

5. Confused about how to present negative numbers in bitwise format

People seem to grasp decimal numbers easiert, so let's build a "ten's complement system". Imagine you store numbers with two digits - no more, no less. Let's start with signless numbers. With two digits, you can represent one hundred different numbers: 00 01 02 03 ... 96 97 98 99 Now let's imagine we also want to have negative numbers. We ...