Notes/UNB/Year 5/Semester 1/CS3113/In class notes.md

60 lines
2.4 KiB
Markdown

## Convert numbers to binary
Number in decimal: 53.7
### Decimal conversion
| Calculation | Remainder/Binary |
| ----------- | ---------------- |
| 53 / 2 = 26 | 1 |
| 26 / 2 = 13 | 0 |
| 13 / 2 = 6 | 1 |
| 6 / 2 = 3 | 0 |
| 3 / 2 = 1 | 1 |
| 1 / 2 = 0 | 1 |
So in binary 110101, as the order is in reverse of the decimals
### Fraction Conversion
| Calculation | Non Decimal Portion/Binary |
| ------------- | -------------------------- |
| 0.7 x 2 = 1.4 | 1 |
| 0.4 x 2 = 0.8 | 0 |
| 0.8 x 2 = 1.6 | 1 |
| 0.6 x 2 = 1.2 | 1 |
| 0.2 x 2 = 0.4 | 0 |
And so on.. so the fraction would be .10110, with 0110 repeating infinitely
So the final number would be 110101.10110...
**Normalization** is the process is the process of adjusting a number so only 1 non zero digit on the left side of a number, i.e. the number is in scientific notation
## Floating point number types
| Precision | Sign | Exponent | Mantissa |
| ----------- | ---- | -------- | -------- |
| single | 1 | 8 | 23 |
| double | 1 | 11 | 52 |
| long double | 1 | 15 | 64 |
Truncation types
**Chopping**: Omit the numbers that we don't want, looking to the first bit that we want to erase
**Rounding**: We should take care about the first digit that we want to omit and adjust the 52nd bit
**Machine Epsilon**: Difference between the smallest floating point number greater than 1 and 1, i.e. the smallest number that when added to 1, will be different than 1
IEEE rounding to nearest role:
1. If we have zero in the 53rd bit, we will round down
2. If we have one as the 53rd bit, we will round up
1. If the 52nd bit is one we will round up
2. If the 52nd bit is zero will round down
Convert a real number to a floating point number:
1. Decimal to binary number
2. Justify step: Shift the radix to the right of the left most one, compensate with the exponent. 100.1 -> 1.0001 x_2^3
3. We do it with respect to p.A d.p 52 numbers ??? I think she means IEEE rounding
There is no need to represent the first bit of the mantissa, since it is always 1 with certain exceptions
Overflow - exponent greater than 1023
Underflow - exponent less than 2^-1074
Normally set to zero
Mean value theorem - *Info and graph in slides*
Taylor's Theorem