Skip to content

Commit 81af303

Browse files
committed
update README
1 parent 775d630 commit 81af303

1 file changed

Lines changed: 1 addition & 38 deletions

File tree

README.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8585
1. $c \cdot 2^q \gets v$
86-
8786
2. $\text{if } v \text{ is regular}$
88-
8987
3. $\quad k \gets \lfloor q \cdot \log_{10}(2) \rfloor$
90-
9188
4. $\text{else}$
92-
9389
5. $\quad k \gets \lfloor q \cdot \log_{10}(2) - \log_{10}(4/3) \rfloor$
94-
9590
6. $\text{end if}$
96-
9791
7. $m \gets \lfloor v \cdot 10^{-k-1} \rfloor$
98-
9992
8. $n \gets v \cdot 10^{-k-1} - m$
100-
10193
9. $ten \gets 10m$
102-
10394
10. $\delta \gets 10n - \lfloor 10n \rfloor$ // fractional part of $10n$
104-
10595
11. $\text{if } \delta = 0.5$
106-
10796
12. $\quad \text{if } \lfloor 10n \rfloor \bmod 2 = 0$
108-
10997
13. $\quad\quad one \gets \lfloor 10n \rfloor$ // round to even
110-
11198
14. $\quad \text{else}$
112-
11399
15. $\quad\quad one \gets \lfloor 10n \rfloor + 1$
114-
115100
16. $\quad \text{end if}$
116-
117101
17. $\text{elif } \delta < 0.5$
118-
119102
18. $\quad one \gets \lfloor 10n \rfloor$ // round to nearest
120-
121103
19. $\text{else}$
122-
123104
20. $\quad one \gets \lfloor 10n \rfloor + 1$ // round to nearest
124-
125105
21. $\text{end if}$
126-
127106
22. $\text{if } v \text{ is irregular}$
128-
129107
23. $\quad \text{if } \delta > 2^{q-2} \cdot 10^{-k}$
130-
131108
24. $\quad\quad one \gets \lfloor 10n \rfloor + 1$
132-
133109
25. $\quad \text{end if}$
134-
135110
26. $\quad \text{if } 2^{q-2} \cdot 10^{-k-1} \geq n$
136-
137111
27. $\quad\quad one \gets 0$
138-
139112
28. $\quad \text{end if}$
140-
141113
29. $\text{else}$
142-
143114
30. $\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-
145115
31. $\quad\quad one \gets 0$ // minimum length
146-
147116
32. $\quad \text{end if}$
148-
149117
33. $\text{end if}$
150-
151118
34. $\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-
153119
35. $\quad one \gets 10$ // minimum length
154-
155120
36. $\text{end if}$
156-
157121
37. $d \gets ten + one$ // information preservation
158-
159122
38. $\text{return } d, k$
160123
---
161124

0 commit comments

Comments
 (0)