Nguyen Le CS147
2.4 Signed Integer Representation – Signed Magnitude – Complement Systems – Unsigned Versus Signed Numbers – Computers, Arithmetic, and Booth’s Algorithm – Carry Versus Overflow Section overview
Unsigned integer representation carries
3 methods of representation Signed magnitude One’s complement Two’s complement
Signed magnitude Signed magnitude representation includes a sign as the first bit of the storage location. A “1” in the high-order bit (or left- most bit) indicates a negative number and the rest of the remaining bits represent the number itself. Ex: +1 and -1 in an 8-bit word would be (+1) (-1)
Signed magnitude addition carries
Overflow Overflow in signed numbers occurs when the sign of the result is incorrect. The sign bit is used only for the sign, so we can’t carry into it. carries (79) (99) (50) =/= 50
Signed magnitude subtraction borrows (99) (79) (20) 99 – 79 = 20
One’s compliment 1 carries (23) (-9) + 1 (14) Flip the bits for all negative numbers. The last carry is added to the sum.
Two’s compliment (9) (-23) (-14) Flip the bits for all negative numbers. Add = = =
2.6Character Codes – Binary-Coded Decimal – EBCDIC – ASCII – Unicode Section overview
Character codes We’ve gone over how digital computers use the binary system to represent and manipulate numeric values, but have yet to consider how these internal values can be converted to a form that is meaningful to humans. This is done through a coding system used by the computer and how the values are stored and retrieved.
BCD Binary Coded Decimal (BCD) is very common in electronics, particularly those that display numerical data, such as alarm clocks and calculators. 4-bit binary form later extended to 6 1265 =
EBCDIC Extended Binary Coded Decimal Interchange Code (EBCDIC) used in IBM mainframe and midrange computer systems 8-bit binary form 1265 =
ASCII The American Standard Code for Information Interchange (ASCII) was created to better transmit data between systems. Defines codes for 32 control characters, 10 digits, 52 letters (upper and lower- case), 32 special characters, and more.
Unicode 16-bit base coding with the capacity to encode the majority of characters used in every language of the world. Unicode also defines an extension mechanism that will allow for the coding of an additional million characters. Default character set of the Java programming language.