MPO 581 Class 2/27 Jan 24, 2011
Topic: Basics of data in computers
Loose ends from last class:
Computers - get set up
Teams
Today's material:
DATA: Bits, nybbles, bytes, words, numbers, characters, arays,
structures, objects, files
A bit: Deep
down: hi vs. lo in a bimodal distribution of voltages.
(aside: energy cost to keeping tails from
overlapping!)
- CONVENTION:
- interpret as Boolean
F and T
- define/interpret as the numbers
0 and 1
Data: A sequence of 0/1 numbers, in a linear order.
- CONVENTION:
big-endian
vs. little-endian
- like reading L->R vs. R->L
3 bits is an octal number (8 values: 0-7)
4 bits is a nybble (16 values; Hexadecimal)
8 bits is a byte
B (can take on 256 different values)
- Byte (number): -128 to 128 (unsigned), or 0 to 255
- Character: Map to the alphabet. ASCII uses 7 bits (128 characters)
- 1D array of characters is a "string"
16 bits (2B) is a short integer
- again, can be signed (-32767 to 32767) or unsigned
4B is a long
integer, about 4 billion possible values
4B is a single-precision
floating point number
- CONVENTION: IEEE
float ( 1 Sign, 23 Mantissa, 8 Exponent)
8B is a double-
"" "" (IEEE)
8B Complex
is 2 floats
16B Complex
is 2 doubles
Wikipedia
on
numbers
in computers
.ppt compilation from top 10-15
Googles of "introduction computer bits bytes float ppt"
Math operations: dependence on data type
Computer operations are not quite the
same as the mathematics they resemble!
Equal sign is left-assignment
- BEWARE: = vs. == (equality test; returns Boolean T/F = 1/0)
The modulo
operation
Integer division
Roundoff error
Arrays of characters or numbers
Arrays (wiki)
of
numbers:
another layer of encoding, more arbitrary conventions
- Indexing order: A[x,y,z,t] or A[t,z,x,y]?
- in memory, it's just a linear sequance of bits...
- Matlab, C, IDL, Python differ
- [] vs. ()
- Counting starts at 0? or 1?
Structures
Several pieces of data bundled together, for labeling convenience.
Really, it's an array of pointers (memory addresses, which are written
as strings of hexidecimal numbers).
- Met/Ocean example: a vertical sounding called S1 {name, lat, lon,
p-array, T(p), u(p), v(p), ...}
- Note: can mix data types (name may be a string)
- Temperature profile at location S1.lat, S1.lon would be S1.T
(an array)
Objects
A bundle {} that contains data, plus
"methods" to act on the data. Object oriented programming (OOP)
is
a different way of thinking and takes some getting used to.
- Example: a class of
objects called soundings
- has an instance or instantiation called S1
- methods might include functions indicated by (), like stability(), shear(), ...
- Ri = S1.stability() / S1.shear()
- instead of Ri = stability(S1.T) / shear(S1.u, S1.v)
- programming toil buried in definition of methods (CONVENTIONS for
irregular/missing data, time, etc,)
- methods might include graphing the data, like skewT()
- myplot = S1.skewT() might be an instance of object type plots
Open questions, assignments, and
loose
ends for next class:
Think more about teams and roles
Testable questions about today's
material:
There are ___ kinds of people
what is x==3?
what is x=3?