# Issue

I cant seem to find answer about how to convert hexadecimal to decimal with Two's Complement example AD100002 i already know how to do the calculation for unsigned but not for signed 2's complement.
Any help will do or exampe)
(thank's for your time)

(Sorry for bad english).

{unsigned} ->(AD100002 = (10 × 16⁷) + (13 × 16⁶) + (1 × 16⁵) + (0 × 16⁴) + (0 × 16³) + (0 × 16²) + (0 × 16¹) + (2 × 16⁰) = 2903506946).

# Solution

The basic explanation of two's complement on a binary/hex value is to flip every digit and then add 1. For example, say we had the following value:

```
0xA5
```

The first thing to do is convert the value to a binary number:

```
0xA5 -> 10100101
```

To perform two's complement, flip all the bits:

```
10100101
||
\/
01011010
```

and then add 1:

```
01011011
```

Converting this binary number to a decimal number yields 91. Therefore, the two's compliment of the hex value "0xA5" is -91.

(If you're treating the hex value as a signed bit representation of an integer, only perform the two's complement if the most-significant bit in the binary representation is 1. If it's 0, treat the rest of the bits as normal.)

Answered By - Abion47 Answer Checked By - Mary Flores (PHPFixing Volunteer)

## 0 Comments:

## Post a Comment

Note: Only a member of this blog may post a comment.