This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pdclib:floatingpoint [2019/10/17 16:27] solar [Fixed Point] |
pdclib:floatingpoint [2019/10/21 10:13] (current) solar [Floating-Point Printout] |
||
---|---|---|---|
Line 157: | Line 157: | ||
Steele & White approach the presentation of their Dragon algorithm as a series of " | Steele & White approach the presentation of their Dragon algorithm as a series of " | ||
- | ==== Fixed Point ==== | + | ==== Fixed Point Fraction Output |
Given: | Given: | ||
Line 207: | Line 207: | ||
* multiply <m>M = 0.015625</ | * multiply <m>M = 0.015625</ | ||
* Fractional part < | * Fractional part < | ||
- | * Second (<m>k = 2</m> loop | + | * Second (<m>k = 2</m>) loop |
- | * multiply <m>R = 0.835</ | + | * multiply <m>R = 0.835</ |
- | * multiply <m>M = 0.15625< | + | * multiply <m>M = 0.15625</m> by <m>B = 10</ |
* Fractional part < | * Fractional part < | ||
* Post-loop | * Post-loop | ||
* Fractional part < | * Fractional part < | ||
* We have <m>N = k = 2</m> fractional digits in our result of < | * We have <m>N = k = 2</m> fractional digits in our result of < | ||
+ | |||
+ | ==== Floating-Point Printout ==== | ||
+ | |||
+ | Given: | ||
+ | |||
+ | * A base //b// floating-point number <m>v = f * b ^ (e - p)</ | ||
+ | |||
+ | Output: | ||
+ | |||
+ | * An approximate representation to base //B//, using exponential notation if the value is very large or very small. | ||
+ | |||
+ | Algorithm (Dragon2): | ||
+ | |||
+ | * Compute <m>v prime = v * B ^ {-x}</ | ||
+ | * Print the integer part of <m>v prime</ | ||
+ | * Print a decimal point | ||
+ | * Take the fractional part of <m>v prime</ | ||
+ | * Apply algorithm < | ||
+ | * If < |