Numbering Systems
Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only
Computers have used a variety of numbering systems (over the years) More primitive to more complex Binary Machine Code (Assembly) Programming Languages Use compilers to make machine code Great many of them!! Ex: Visual Basic.NET
assume cs:cseg,ds:cseg,ss:nothing,es:nothing jmp p150; start-up code jumpval dd 0; address of prior interrupt signature dw whozat; program signature statedb 0; '-' = off, all else = on waitdw 18; wait time - 1 second or 18 ticks hourdw 0; hour of the day atimedw 0ffffh; minutes past midnite for alarm acountdw 0; alarm beep counter - number of seconds (5) atonedb 5; alarm tone - may be from 1 to the ; higher the number, the lower the frequency alengdw 8080h; alarm length (loop count) may be from 1-FFFF dhoursdw 0; display hours db ':' dminsdw 0; display minutes db ':' dsecsdw 0; display seconds db '-' ampmdb 0; 'A' or 'P' for am or pm
Look at the evolution of one simple program here here
APL: A mathematical language. (~R ∊ R ∘.×R)/R←1↓ ⍳ R ‘ Find primes 1-R ALGOL: First second generation language. BEGIN FILE F (KIND=REMOTE); EBCDIC ARRAY E [0:11]; REPLACE E BY "HELLO WORLD!"; WHILE TRUE DO BEGIN WRITE (F, *, E); END; END.
C: General purpose programming. #include int main(void) { printf("hello, world\n"); return 0; } Basic: Many versions since then. INPUT "What is your name: ", UserName$ PRINT "Hello "; UserName$ DO INPUT "How many stars do you want: ", NumStars Stars$ = STRING$(NumStars, "*") PRINT Stars$ DO INPUT "Do you want more stars? ", Answer$ LOOP UNTIL Answer$ <> "" Answer$ = LEFT$(Answer$, 1) LOOP WHILE UCASE$(Answer$) = "Y" PRINT "Goodbye "; UserName$
VB.NET: Visual Programming with.NET libraries. Module Module1 Sub Main() Console.WriteLine("Hello, world!") End Sub End Module This is NOT the visual version of the program (stay tuned for that!) This is NOT the pinnacle of programming It is, however, a very useful, very easy to learn language
Before we can start to program, we need to understand the basic numbering systems From time to time they will be used in our code Once upon a time, they were essential to programming. Now they are merely useful Several basic numbering systems: Decimal Binary Octal Hexadecimal
Base 10 numbers Numbering system we all grew up with For example: 1,050,423 We all know how to manipulate these numbers Addition, subtraction, multiplication, etc Many ways to use these numbers. Ex: AbacusAbacus Other numbering systems are no different really Just a different base than 10
What computers really use Base 2 Only symbols used are: 0, 1 Each digit represents a power of 2 Tutorial:
Base 8 “Octa” Not used much anymore Used a LOT in early computing Group three binary digits together Each group forms numbers from 0-7 Used for one common task today: ASCIIASCII
Base 16 Digits are: ABCDEF Each digit is a power of 16 16^0 16^1 16^2 Etc Click here for more information
New Math (1964)