CS2650 PC Architecture

Data Representation – Numeric conversions

 

 

To convert a base 10 (decimal) number to its 16 bit signed integer representation:

 

  1. Is the number negative?
    1. No – Convert the number to 4 hex digits
    2. Yes

1)      Convert the number to 4 hex digits

2)      Flip the bits of each digit

3)      Add 1

 

To convert a 16 bit signed integer number to its decimal equivalent:

 

1.                  Is the first digit greater than 7? (is the number negative?)

a.       No – Convert the number to decimal.

b.      Yes

1)      Flip the bits of each digit

2)      Add 1

3)      Convert the number to decimal and put a minus sign in front.

 

 

Examples:


 -1330 => FACEh

Flowchart: Alternate Process: -1330 Flowchart: Alternate Process: Is negative so we first convert to 4 hex digits -> 0532h
Flowchart: Alternate Process: Then flip the bits of each digit 
FACDh
Flowchart: Alternate Process: Then we add 1 to the hex number:
FACD + 1 = FACEh
 





 

CAFEh => -13570