Data Representation
TOC
Data Representation
Units
- bit, byte, kilobytes, megabytes, gigabytes, terabytes, petabytes
- 1000 base, MB
- 1024 base, MiB
- b vs B
Numerical
Encoding
- Excess 3
- BCD
- Exercise: base 10, 9’s complement vs 10’s complement
Integers(fixed point)
- 2’s complement: mainly used
- 1’s complement: postive & negative 0
- Sign and magnitude
- Gray code
- Benefit: filp 1 bit at a time, has a good pattern
Floating point
- Sign and magnitude
- Float(32bits, 1 + 8 + 23), excess-127
- Double(64bits, 1 + 11 + 48)
Overflow & Underflow
Conversion
- 10110.0011~(2)~
- 1101~(2)~
- unsigned
- signed
- float: 1 01111111 00000 00000 00000 00000 001 = -(1+2^-23^)
Text
Audio
- Sampling
- Sample rate(e.g. 44100Hz)
- Duration(e.g. 3s)
- Quantization
- Bit per sample(bit depth, e.g. 24 bit)
- Encoding
- Lossy: mp3, ape…
- Lossless: wav, flac…
- Bit rate = sample rate * bit depth (e.g. 1033kbps)
Images
- Raster(bitmap) graphics: bmp, jpeg, gif…
- Vector graphics: svg…
- Resolution
- Color depth
- True color: 24 bits, 3 channels
- Indexed color: a subset color of true color
Videos
- Mpeg4, avi, mkv…
Questions
- Convert the 1010.01011~(2)~ to decimal and octal.
- Convert the 734.2371~(8)~ to decimal and binary.
- Convert the 31.96~(10)~ to octal and binary.
- Represent 31.96~(10)~ with single precision floating point.
- When will overflow and underflow happen?
- Give 1 example of overflowing and 1 example of underflowing.
- If a piece of audio has 500 bytes, duration of 5s, bit depth is 10bit. What’s its bit rate and sampling rate?
- How do resolution and color depth affect an image?