Lecture3 - Lecture 3 Number Representation Integers Several...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 3 Number Representation Integers - Several bytes together are used to store integers - 2 bytes (1/2 word) form a short integer - 4 bytes (1 word) form a regular integer - 8 bytes (2 words) form a long integer - Computers work with fixed sized numbers, aka finite precision numbers (fixed when the computer is designed and built). o What does this mean? Computers can only deal with numbers that can be represented by a fixed number of digits. Example: Only positive integer numbers represented by, say, 3 decimal digits 1000 unique numbers (000, 001, 002, …, 999) Impossible numbers: > 999; negative numbers; fractions; irrational numbers; complex numbers
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Radix Number System - Also known as positional number system , or base k system - In a k radix system there are k symbols, typically 0 to ( k -1) - For integers, value of the i th digit d is: d*b i where b is the base o i starts from 0 and is counted from right to left for whole number o i starts from -1 and is counted from left to right for fractions Binary Numbers (Radix – 2) - We have never before had to worry about how many decimal places are required to represent a number - But since we have finite precision number this is a concern here - Typically, one memory word is used to store a number - Number of bits is fixed (even with long integers or double precision numbers) - Other Common Radices o Octal (base 8, radix – 8) : requires 8 symbols, symbols 0, …, 7 o Decimal (base 10, radix –10) : requires 10 symbols, symbols 0, …, 9 o Hexadecimal (base 16, radix – 16) : requires 16 symbols, 0, …, 9, A, B, C, D, E, F
Background image of page 2
- ALWAYS write the radix or base along with the number to eliminate any ambiguity o Example: 111 2 vs . 111 16 in decimal: 7 vs . 273 HEX Values (base-16) - HEX is commonly used in SPIM. - Memory Address are usually represented in HEX - ASCII characters should be referred to in their HEX form in SPIM - Example: 41 in HEX is the ASCII character ‘A’ 0 100 0001 0x41 (this how you should refer to it in your programs) - The only way to refer to the non-printable ASCII characters (0x00 - 0x1F) is to use their HEX values
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Radix Conversions Decimal to Binary - Divide the value by 2 at every step. - Collect the Remainders. - Remainders represent the binary number, placing them in order from right-to-left. Or
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/12/2010 for the course CSE 220 taught by Professor Staff during the Spring '08 term at SUNY Stony Brook.

Page1 / 9

Lecture3 - Lecture 3 Number Representation Integers Several...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online