- #1

- 14

- 0

how would you convert a negative number into a hexadecimal format?

- Thread starter majeedh
- Start date

- #1

- 14

- 0

how would you convert a negative number into a hexadecimal format?

- #2

- 3,556

- 1,327

There are a couple of methods of doing so.how would you convert a negative number into a hexadecimal format?

One is to use a sign bit, where the MSB represents the sign (1 meaning negative. Thus 01 would represent +1 and 81 would represent -1 for two digit Hex numbers

Another is two's complement. Here you invert all the bits and then add 1 to the result. thus 01 still represents +1 and FF represents -1.

The advantage of two's complement is that it is easy to do with logic gates, and gives a result that you can add directly. For example, FF + 01 =00 (ignoring the carry)

other examples:

0C + FA = 07 (12 + (-5) = +7)

05 + F3 = F9 (5+(-12) =-7)

- #3

- 15,393

- 684

One problem with signed magnitude and ones complement notation is that both have positive and negative zero as different numbers. This is one of the reasons these two techniques have largely been abandoned.

Two's complement is the dominant mechanism by which negative numbers are represented in binary. There is one important exception: Excess-n notation is used to represent the exponent in the IEEE floating point representation.

- Last Post

- Replies
- 3

- Views
- 539

- Last Post

- Replies
- 2

- Views
- 8K

- Last Post

- Replies
- 0

- Views
- 2K

- Replies
- 2

- Views
- 5K

- Replies
- 8

- Views
- 4K

- Replies
- 22

- Views
- 2K

- Last Post

- Replies
- 5

- Views
- 817

- Replies
- 2

- Views
- 3K

- Replies
- 1

- Views
- 9K

- Replies
- 6

- Views
- 5K