data representation Flashcards
word size
number of bits a computer’s CPU can process at once
(amount register can hold + manipulate )
word
unit of data defining the number of bits that move around a computer from 1 component to another
made of bits
possible combinations
2^n
where n = no of bits
byte sizes
8 bits = 1 byte
1024 bytes - 2^10 bytes Kilobyte
1024 x 1024 bytes = 2^20 bytes Megabyte
Gigabyte
Terabyte
Petabyte
Exabyte
unsigned int
uses all of allocated bits to represent value
unsigned int
uses all of allocated bits to represent value
largest no. in an unsigned int
2^n - 1
one less than no. of combinations (since 0 is included as one of the values)
smallest no in an unsigned int
0
sign in binary
left most bit indicates the sign
0= positive 1 = negative
two’s complement
soln to adding neg binaries
- make no. binary (add leading 0s)
- reverse (swap 0s and 1s) and add sign
-add 1
check : if pos no + its 2s complement = 0. (ans is 8 bits)
from 2s complement to decimal
- reverse 0s and 1s
- add 1
-convert to decimal equivalent - add - sign
largest no in signed int
2^(n-1) - 1
1 less bit because sign takes 1 bit
smallest signed number
-2^(n-1)
overflow
try to store a value in a data type that is outside the range data type
cause significant logical errors
normalised form
to understand real numbers
0.nnnn x 10^k (all digits moved to fraction part)
ensure no loss of accuracy- 0 can be excluded
nnnn - mantissa k- exponent
signed
lowest exponent: -2^(k-1), highest 2^(k-1) -1
mantissa limited to 9 digits - additional will be truncated/rounded - inaccurate
if too few digits for exponent- overflow