## What does this mean?

Put your programming skills to the test in these challenges.

### What does this mean?

I was trying to understand bytes better and I came across this page and wanted to understand the term "signed two's complement integer."

What does "two's" mean in this case because I don't get it?

ghostheadx2
Contributor

Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)

### Re: What does this mean?

Representing the number in binary, it has a parity bit that will represent the sign value(the first bit is the sign bit 0 = positive, 1= negative).
This means since a byte has 8 bits, the values it can take is max 2 at the power of 7(128 values), which are the first 7 bits, where the last bit is the sign.

Code: Select all
`from 0 to 127       = 0000 0000 - 0111 1111from (-128) to (-1) = 1000 0000 - 1111 1111`

ghost107
Poster

Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)

### Re: What does this mean?

Aah. I see. So the ASCII character in base 127 represents the same number in binary. so that means nul is zero and whatever the next number in ASCII is is 10. Then the third word means 11 or 3, etc.?
ghostheadx2
Contributor

Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)

### Re: What does this mean?

Its more about the sign:
The ones complement is the number in binary with inverted bits ( 1 = 001 and -1 = 110)
Code: Select all
`Bin    S   U000 =  0 = 0001 =  1 = 1010 =  2 = 2011 =  3 = 3100 = -3 = 4101 = -2 = 5110 = -1 = 6111 = -0 = 7`

The Two's complement is the ones complement+1( -1 = ~001+1 = 110+1 = 111), which eliminates the need of having two 0
Code: Select all
`Bin    S   U000 =  0 = 0001 =  1 = 1010 =  2 = 2011 =  3 = 3100 = -4 = 4101 = -3 = 5110 = -2 = 6111 = -1 = 7`

ghost107
Poster

Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)

Return to Programming

### Who is online

Users browsing this forum: No registered users and 0 guests