User Tools

Site Tools


pdclib:floatingpoint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
pdclib:floatingpoint [2019/10/17 17:18]
solar [Floating-Point Printout (Dragon2)]
pdclib:floatingpoint [2019/10/18 14:40]
solar [Fixed Point Fraction Output]
Line 207: Line 207:
     * multiply <m>M = 0.015625</m> by <m>B = 10</m> for new <m>M = 0.15625</m>     * multiply <m>M = 0.015625</m> by <m>B = 10</m> for new <m>M = 0.15625</m>
     * Fractional part <m>0.835</m> is larger than mask <m>0.15625</m>, and smaller than <m>1 - 0.15625 = 0.84375</m>, so <m>6</m> is our first (fractional) digit, and the loop continues     * Fractional part <m>0.835</m> is larger than mask <m>0.15625</m>, and smaller than <m>1 - 0.15625 = 0.84375</m>, so <m>6</m> is our first (fractional) digit, and the loop continues
-  * Second (<m>k = 2</m> loop +  * Second (<m>k = 2</m>loop 
-    * multiply <m>R = 0.835</m> by <m>B = 10</m> for integral part <m>8</m>, fractional part <m>0.35<m> +    * multiply <m>R = 0.835</m> by <m>B = 10</m> for integral part <m>8</m>, fractional part <m>0.35</m> 
-    * multiply <m>M = 0.15625<m> by <m>B = 10</m> for new <m>M = 1.5625</m>+    * multiply <m>M = 0.15625</m> by <m>B = 10</m> for new <m>M = 1.5625</m>
     * Fractional part <m>.35</m> is smaller than mask <m>1.5625</m>, and not smaller than <m>1 - 1.5625 = -0.5625</m>, so the loop terminates     * Fractional part <m>.35</m> is smaller than mask <m>1.5625</m>, and not smaller than <m>1 - 1.5625 = -0.5625</m>, so the loop terminates
   * Post-loop   * Post-loop
Line 215: Line 215:
     * We have <m>N = k = 2</m> fractional digits in our result of <m>0.68</m>, which is the smallest <m>N</m> that uniquely identifies our original <m>f = .10110</m>     * We have <m>N = k = 2</m> fractional digits in our result of <m>0.68</m>, which is the smallest <m>N</m> that uniquely identifies our original <m>f = .10110</m>
  
-==== Floating-Point Printout (Dragon2) ====+==== Floating-Point Printout ====
  
 Given: Given:
Line 224: Line 224:
  
   * An approximate representation to base //B//, using exponential notation if the value is very large or very small.   * 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}</m>, where <m>x</m> is chosen so that the result either is between 1 / //B// and 1, or between 1 and //B//
 +   * Print the integer part of <m>v prime</m>
 +   * Print a decimal point
 +   * Take the fractional part of <m>v prime</m>, let <m>n = p - floor ( log_ b v prime ) - 1</m>
 +   * Apply algorithm <m>(FP)^3</m> to //f// and //n//
 +   * If <m>x</m> was not zero, append the letter "E" and a representation of the scale factor <m>x</m>
pdclib/floatingpoint.txt · Last modified: 2019/10/21 10:13 by solar