@@ -83,23 +83,13 @@ Trivial, already ubiquitous in the literature.
83
83
84
84
Drawn from < https://hal.science/hal-03282794v5/document >
85
85
86
- function γsectionOO(a,b)
87
- g = γ(a,b)
88
- hi = ceilint(a,b,g)
89
- k = rand(DiscreteUniform(1, hi-1))
90
- (k1,k2) = splitint64(k)
91
- if abs(a) <= abs(b)
92
- return 4* (b/4-k1* g)-k2* g
93
- else
94
- return 4* (a/4+k1* g)+k2* g
95
- end
96
-
97
86
1 . Let |step| be the largest step between floats between |min| and |max|.
98
87
2 . Let |values| be ceilint(|min|, |max|, |step|).
99
88
3 . Let |k| be a random int in (1, |values| - 1), using Canon's method.
100
- 4 . Let |k1| be |k| >> 2, and |k2| be the low 2 bits of |k|.
101
- 5 . If abs(|min|) <= abs(|max|), return 4\* (|max|/4 - |k1|\* |step|) - |k2|\* |step|.
102
- Otherwise, return 4\*(|min|/4 - k1\*|step|) + |k2|\*|step|.
89
+ 4 . Multiply with 54 bits of precision:
90
+ 1. Let |k1| be |k| >> 2, and |k2| be the low 2 bits of |k|.
91
+ 2. If abs(|min|) <= abs(|max|), return 4\*(|max|/4 - |k1|\*|step|) - |k2|\*|step|.
92
+ Otherwise, return 4\*(|min|/4 - k1\*|step|) + |k2|\*|step|.
103
93
104
94
105
95
ceilint(|a|, |b|, |g|), implements ceil((b-a)/g) perfectly, and without overflow
0 commit comments