@@ -79,83 +79,46 @@ The following algorithmic process is derived from a variant of the Schubfach alg
7979------
8080### algorithm : The xjb Algorithm for Float-to-Decimal Conversion
8181
82- ** Input** : $c,q$ ; Floating-point components $c$ (significand) and $q$ (exponent)
82+ ** Input** : $c,q$ ; Floating-point components $c$ (significand) and $q$ (exponent)
8383** Output** : $d,k$ ; Decimal representation $d \cdot 10^k$ satisfying the SW principle
8484
85851 . $c \cdot 2^q \gets v$
86-
87862 . $\text{if } v \text{ is regular}$
88-
89873 . $\quad k \gets \lfloor q \cdot \log_ {10}(2) \rfloor$
90-
91884 . $\text{else}$
92-
93895 . $\quad k \gets \lfloor q \cdot \log_ {10}(2) - \log_ {10}(4/3) \rfloor$
94-
95906 . $\text{end if}$
96-
97917 . $m \gets \lfloor v \cdot 10^{-k-1} \rfloor$
98-
99928 . $n \gets v \cdot 10^{-k-1} - m$
100-
101939 . $ten \gets 10m$
102-
1039410 . $\delta \gets 10n - \lfloor 10n \rfloor$ // fractional part of $10n$
104-
1059511 . $\text{if } \delta = 0.5$
106-
1079612 . $\quad \text{if } \lfloor 10n \rfloor \bmod 2 = 0$
108-
1099713 . $\quad\quad one \gets \lfloor 10n \rfloor$ // round to even
110-
1119814 . $\quad \text{else}$
112-
1139915 . $\quad\quad one \gets \lfloor 10n \rfloor + 1$
114-
11510016 . $\quad \text{end if}$
116-
11710117 . $\text{elif } \delta < 0.5$
118-
11910218 . $\quad one \gets \lfloor 10n \rfloor$ // round to nearest
120-
12110319 . $\text{else}$
122-
12310420 . $\quad one \gets \lfloor 10n \rfloor + 1$ // round to nearest
124-
12510521 . $\text{end if}$
126-
12710622 . $\text{if } v \text{ is irregular}$
128-
12910723 . $\quad \text{if } \delta > 2^{q-2} \cdot 10^{-k}$
130-
13110824 . $\quad\quad one \gets \lfloor 10n \rfloor + 1$
132-
13310925 . $\quad \text{end if}$
134-
13511026 . $\quad \text{if } 2^{q-2} \cdot 10^{-k-1} \geq n$
136-
13711127 . $\quad\quad one \gets 0$
138-
13911228 . $\quad \text{end if}$
140-
14111329 . $\text{else}$
142-
14311430 . $\quad \text{if } 2^{q-1} \cdot 10^{-k-1} > n \text{ or } \left( 2^{q-1} \cdot 10^{-k-1} = n \text{ and } c \bmod 2 = 0 \right)$
144-
14511531 . $\quad\quad one \gets 0$ // minimum length
146-
14711632 . $\quad \text{end if}$
148-
14911733 . $\text{end if}$
150-
15111834 . $\text{if } 2^{q-1} \cdot 10^{-k-1} > 1-n \text{ or } \left( 2^{q-1} \cdot 10^{-k-1} = 1-n \text{ and } c \bmod 2 = 0 \right)$
152-
15311935 . $\quad one \gets 10$ // minimum length
154-
15512036 . $\text{end if}$
156-
15712137 . $d \gets ten + one$ // information preservation
158-
15912238 . $\text{return } d, k$
160123---
161124
0 commit comments