90 likes | 111 Views
CS 101 – Sept. 9. Finish real numbers Representing information Not just in binary, it has to be organized : Linear Non-linear Network: graph Hierarchy: tree. Real-number rep’n. Also called “Floating-point” Size is 32 or 64 bits. Based on “ binary scientific notation ”
E N D
CS 101 – Sept. 9 • Finish real numbers • Representing information Not just in binary, it has to be organized: • Linear • Non-linear • Network: graph • Hierarchy: tree
Real-number rep’n • Also called “Floating-point” • Size is 32 or 64 bits. • Based on “binary scientific notation” • Only one scheme is used: • 1 bit for sign • 8 bits for exponent • 23 bits for mantissa • Big mantissa precision
Distribution • 8 bit exponent 256 different exponents • Biggest number ~ 1038. • Smallest (+) number ~ 10–38. • 23 bit mantissa 8 million numbers per power of 2. • Three kinds of numbers can’t be represented. (Where are they?)
Linear organization • Definite begin & end • One logical way to read (forwards) • Used for: text, audio, images, video • One file consists of many “cells” of data • Individual character, musical note, pixel on screen, frame of movie • It’s convenient if each “cell” is a whole number of bytes. 1 byte = 8 bits.
Digitizing data • Text • Break up information into characters • Each character represented by a binary number • How many different binary numbers will we need? • Need to encode formatting commands as well. E.g. some text may be in a different font. • Music/audio • Can break up song into notes • What information is in a “note” ? • How frequently do notes come? Sampling
Digitizing data (2) • Images • Break up picture into pixels, each becomes a number. • How many pixels do we need? • The pixel values are colors. How many different colors do we want? • Video • A sequence of images. • How many images per second? • (Also need to include sound on the side.)
Non-linear organization • Either there’s no logical begin/end to information, or many ways to travel thru it. Graph (network) Tree (hierarchy)
Tree example • We use trees to represent mathematical expressions. There’s a hierarchy because of the order of operations. * + – 3 4 7 8
Normally we’d write (3 + 4) * (7 – 8) More efficient to use “postfix” or RPN notation: 3 4 + 7 8 – * Representing a tree * + – 3 4 7 8