+ All Categories
Home > Documents > Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only...

Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only...

Date post: 25-Dec-2015
Category:
Upload: lora-mason
View: 219 times
Download: 1 times
Share this document with a friend
15
Numbering Systems
Transcript
Page 1: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

Numbering Systems

Page 2: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

Computers do not use English.

They do not use words

Computers run on NUMBERS only

Those numbers are in BINARY only

Page 3: 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

Page 4: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

0101010101000101010101010101010101010100101010101011010101010100100101010101010101010010101010101010100000101011111001010101010010100101010101101001010101010101001010101010010101010100010101010101010101010101010010101010101101010101010010010101010101010101001010101010101010000010101111100101010101001010010101010110100101010101010100101010101001010101010001010101010101010101010101001010101010110101010101001001010101010101010100101010101010101000001010111110010101010100101001010101011010010101010101010010101010101010101011010101010101010101010101010101010101011111101010101010101010101010100001010101010101010101010010101010101001010101010101010101010101010010101010100100000111010000

Page 5: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

assume cs:cseg,ds:cseg,ss:nothing,es:nothingjmp p150 ; start-up code

jumpval dd 0 ; address of prior interruptsignature dw whozat ; program signaturestate db 0 ; '-' = off, all else = onwait dw 18 ; wait time - 1 second or 18 tickshour dw 0 ; hour of the dayatime dw 0ffffh ; minutes past midnite for alarmacount dw 0 ; alarm beep counter - number of seconds (5)atone db 5 ; alarm tone - may be from 1 to 255 - the

; higher the number, the lower the frequencyaleng dw 8080h ; alarm length (loop count) may be from 1-FFFF

dhours dw 0 ; display hoursdb ':'

dmins dw 0 ; display minutesdb ':'

dsecs dw 0 ; display secondsdb '-'

ampm db 0 ; 'A' or 'P' for am or pm

Page 6: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

Look at the evolution of one simple program here

Page 7: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

APL: 1957. A mathematical language.

(~R∊R∘.×R)/R←1↓⍳R ‘ Find primes 1-R

ALGOL: 1960. 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.

Page 8: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

C: 1972. General purpose programming.#include <stdio.h> int main(void) { printf("hello, world\n"); return 0; }

Basic: 1964. 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$

Page 9: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

VB.NET: 2003. 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

Page 10: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

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

Page 11: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

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: Abacus Other numbering systems are no different really Just a different base than 10

Page 12: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

What computers really use Base 2 Only symbols used are: 0, 1 Each digit represents a power of 2 Tutorial:

http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary.html

Page 13: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

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: ASCII

Page 14: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

Base 16 Digits are: 0123456789ABCDEF Each digit is a power of 16

16^0 16^1 16^2 Etc

Click here for more information

Page 15: Numbering Systems. Computers do not use English. They do not use words Computers run on NUMBERS only Those numbers are in BINARY only.

New Math (1964)


Recommended