01-11-2012, 01:53 PM
Number Systems
Number Systems.ppt (Size: 75.5 KB / Downloads: 24)
What should init() do ?
Read the HTML <PARAM...> tags (2)
Convert the string to numbers
Calculate values to be displayed
They don't change as the program runs
What are the consequences of this design?
Where should these variables or objects be declared?
Should the display be numbers or strings?
Import versus Specification
We can import the package we need
import java.awt.Graphics;
import java.awt.*;
and then use it without the specification
public void paint( Graphics g ) { … }
or specify it as we need it
public void paint( java.awt.Graphics g )
The Math library
The Math Library is already available
So is everything else in the package java.lang
These methods don't require that we have an object of the type Math class defined
How do we find the square root function?
Look up the Math class documentation
Textbook, IDE, Sun’s API web pages
Number Systems
Roman Numerals
Symbols for 1, 5, 10, 100, 1000 and so on
I, V, X, C, M
The number and position of symbols is used to indicate the value
Minimize number of symbols
III is 3, but 4 is IV
Think about the difficulty of multiplying 2 four digit numbers
Converting Between Representations
In this class we'll convert from binary to decimal and back
We won't concern ourselves with
Octal
Group bits into sets of 3
Range 0 through 7 (decimal)
Hexadecimal
Group bits into sets of 4
Range 0 through 15 (decimal)
0 through F (hexadecimal)