29
Surprise: 17
(binary: 11110111 and 10001)
That's what calc.exe is good for...
-44(10) = D4(16) = 11010100(2)
15
15(10)=01111(2)
-15(10)=10001(2)
1 0111010 signed 2's complement integer.
27
8-bit 2s complement representation of -19 is 11101101 For 1s complement invert all the bits. For 2s complement add 1 to the 1s complement: With 8-bits: 19 � 0001 0011 1s � 1110 1100 2s � 1110 1100 + 1 = 1110 1101
You can detect overflow if the result turns out to be negative (which is the same as checking to see if the sign bit is 1). For example if you tried to add 5 and 6 in to 4-bit 2s complement, you would get 0101 + 0110 = 1011, which is a negative number since the sign bit (the 1 on the left) is a 1. This is an overflow.
One-complement applies to binary values, not decimal values. Therefore when we say the ones-complement of a decimal value we mean convert the value to binary, invert all the bits (the ones-complement), then convert the result back to decimal. For example, the decimal value 42 has the following representation in 8-bit binary: 00101010 If we invert all the bits we get 11010101 which is 213 decimal. Thus 213 is the ones-complement of 42, and vice versa. However, it's not quite as straightforward as that because some (older) systems use ones-complement notation to represent signed values, such that 11010101 represents the decimal value -42. The problem with this notation is that the ones-complement of 00000000 is 11111111 which means the decimal value 0 has two representations, +0 and -0 respectively. In the real-world, zero is neither positive nor negative. To resolve this problem, modern systems use twos-complement to represent signed values. The twos-complement of any value is simply the ones-complement plus one. Thus the ones-complement of 42 becomes -43, therefore the twos-complement of 42 is -43+1 which is -42. Thus -42 is represented by the binary value 11010110 in twos-complement notation. With twos-complement, there is only one representation for the value 0. This is because the ones-complement of 00000000 is 11111111 and if we add 00000001 we get 00000000. Note that we don't get 100000000 because the result cannot have any more bits than were in the original value. When an "overflow" occurs, we cycle back to zero. As a result, incrementing and decrementing signed values has exactly the same logic as incrementing or decrementing unsigned values and flipping the sign of any value is only slightly more complicated by the extra addition operation. However, flipping the sign of a value is a much rarer operation than counting so the cost is trivial compared to the cost of counting operations using ones-complement (because there are two values for zero). Note that ones-complement notation allows an 8-bit value to store signed values in the range -127 to +127, whereas twos-complement allows a range of -128 to +127 (through the elimination of the extra zero). But in unsigned notation, both allow the same range: 0 to 255. Although we rarely encounter ones-complement notation, it is important to keep in mind that not all systems use twos-complement notation, particularly when working with low-level but portable programming languages. This is the reason why both the C and the C++ standards state that the range of an 8-bit signed value is only guaranteed to store values in the range -127 to +127.
Two's complement is the normal implementation of signed integers, so just take the negative. int a = 123; int b = -a; /* b now equals -123 */ The actual implementation of two's complement notation is that, to make something negative, simply invert the bits and then add 1. 12310 = 00000000011110112 (using 16 bit notation) Invert and you get 111111111000100. Add one and you get 111111111000101, so... -12310 = 1111111110001012
1's complement and 2's complement relate to the way negative integers are represented in computer memory. With 1's complement, all the bits are inverted. This results in there being two representations for the value 0 because 00000000 is +0 while 11111111 is -0. But in the real world 0 is neither positive nor negative. To resolve this, 2's complement inverts all the bits and then adds 1 ignoring any overflow, such that 11111111 + 00000001 = 00000000. With 1's complement, the valid range of integers for an 8-bit value is -127 to +127 but with 2's complement it is -128 to +127 because we eliminate the redundant 0 value. Most modern systems use 2's complement but there are still systems using 1's complement.
87
The complement of 43% is 47%, as 43% + 47% = 90%.
8-bit 2s complement representation of -19 is 11101101 For 1s complement invert all the bits. For 2s complement add 1 to the 1s complement: With 8-bits: 19 � 0001 0011 1s � 1110 1100 2s � 1110 1100 + 1 = 1110 1101
43
1
The following answer is correct only if b is the measure of an angle in degrees. The complement is 90-43 = 47 degrees.
90 - 43 = 47 degrees.
-15 is 11111111 and 2s com is 1111 0001
To get the 2s complement, change all 1 bits to 0s and all 0 bits to 1s, and add 1 to the result. So the 2s complement of the 8-bit binary number 10001011 is the binary integer 01110101. If you want that in decimal, then remember that each place value column is twice the value of the place value column to its right, and the rightmost place value column for an integer is 1. Thus 01110101 in decimal is 64 + 32 + 16 + 4 + 1 = 117 (And 10001011 as a signed 8-bit binary integer represents the decimal integer -117.)
43 degrees
It is an angle of 43 degrees
43 degrees