0% found this document useful (0 votes)
42 views

Conversion: Decimal Binary Hexadecimal Addition in Other Bases

This document discusses number representation and arithmetic in different number bases. It covers converting between decimal, binary, and hexadecimal, as well as addition and subtraction in these bases. It also discusses representing negative numbers, including using two's complement to represent signed integers in binary. The key trade-off of using signed vs. unsigned integers is how negative numbers are handled.

Uploaded by

Pallavi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Conversion: Decimal Binary Hexadecimal Addition in Other Bases

This document discusses number representation and arithmetic in different number bases. It covers converting between decimal, binary, and hexadecimal, as well as addition and subtraction in these bases. It also discusses representing negative numbers, including using two's complement to represent signed integers in binary. The key trade-off of using signed vs. unsigned integers is how negative numbers are handled.

Uploaded by

Pallavi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Created by Anthony Estey – Used by Miguel Nacenta

CSC 106 – Unit 2: Numbers

Conversion: Decimal  Binary  Hexadecimal Addition in other bases


Think about how we do addition in our decimal (base-10) number system:
1) Convert (4c3)16 to binary (base-2) and decimal (base-10):
196
+ 347

1) Add the following two binary numbers:

(10010101)2
+ (00110110)2
Representing negative numbers
In binary, the left-most bit is often used to represent the sign (whether the
number is positive or negative). This is called a signed integer:
• 0 means the number is positive 2) Add the following two binary numbers:
• 1 means the number is negative
(01101111)2
Unsigned vs signed integers + (00111111)2
Consider that we are working with 8-bit integers (1-byte):
• a signed integer uses the leftmost bit to represent the sign, and the
remaining 7-bits to represent the magnitude of the number
• an unsigned integer uses all 8 bits to represent the magnitude 3) Add the following two hexadecimal numbers:
Example:
(1A57)16
+ (32C4)16

What are the trade-offs associated with using signed or unsigned integers? 4) Add the following two hexadecimal numbers:

(49EC)16
+ (7F3D)16
Created by Anthony Estey – Used by Miguel Nacenta
CSC 106 – Unit 2: Numbers

Subtraction in other bases Two’s Complement


Think about how we do subtraction in the base-10 number system: When working with signed integers, we know that the left-most bit
represents the sign (whether the number is positive or negative).
1546
But how do we represent negative numbers?
- 793
A common signed representation is called two’s complement:
• positive numbers are represented the same was as before
Be careful: We need to remember what the carry/borrow value represents: • negative numbers are represented differently:
o start with the positive binary representation
• In base-10 we borrow 10 (ten) from the column to the left
o negate all the bits (flip the 1s to 0s and 0s to 1s)
• In base-2 we borrow 10 (two) from the column to the left
o add 1 to the negated value
• In base-16 we borrow 10 (sixteen) from the column to the left
Example:
1) Subtract the following two binary numbers:
(13)10  (00001101)2

10101101
- 00011010

Why are negative numbers represented in two’s complement?


2) Subtract the following two hexadecimal numbers: • In decimal notation, what is (-13) + 1?

DEA9
-4FBD
Let’s take a look in binary:

(-12)10 represented in binary is: (11110100)2

You might also like