... |
... |
@@ -136,5 +136,45 @@ |
136
|
136
|
(ext:with-float-traps-masked (:overflow)
|
137
|
137
|
(* 100 most-negative-double-float)))))
|
138
|
138
|
|
139
|
|
-
|
140
|
|
- |
|
|
\ No newline at end of file |
|
139
|
+(define-test float-ratio.single
|
|
140
|
+ (:tag :issues)
|
|
141
|
+ ;; least-positive-single-float is 1.4012985e-45. Let's test with
|
|
142
|
+ ;; some rationals from 7/10*10^-45 to 1.41*10^-45 to make sure they
|
|
143
|
+ ;; return 0 or least-positive-single-float
|
|
144
|
+ (let ((expo (expt 10 -45)))
|
|
145
|
+ ;; 7/10*10^-45 is just under halfway between 0 and least-positive,
|
|
146
|
+ ;; so the answer is 0.
|
|
147
|
+ (assert-equal 0f0 (kernel::float-ratio-float (* 7/10 expo) 'single-float))
|
|
148
|
+
|
|
149
|
+ ;; These are all more than half way to
|
|
150
|
+ ;; least-positive-single-float, so they should return that.
|
|
151
|
+ (assert-equal least-positive-single-float
|
|
152
|
+ (kernel::float-ratio-float (* 8/10 expo) 'single-float))
|
|
153
|
+ (assert-equal least-positive-single-float
|
|
154
|
+ (kernel::float-ratio-float (* 1 expo) 'single-float))
|
|
155
|
+ (assert-equal least-positive-single-float
|
|
156
|
+ (kernel::float-ratio-float (* 14/10 expo) 'single-float))
|
|
157
|
+ (assert-equal least-positive-single-float
|
|
158
|
+ (kernel::float-ratio-float (* 2 expo) 'single-float))))
|
|
159
|
+
|
|
160
|
+(define-test float-ratio.double
|
|
161
|
+ (:tag :issues)
|
|
162
|
+ ;; least-positive-double-float is 4.9406564584124654d-324. Let's
|
|
163
|
+ ;; test with some rationals from about 2*10^-324 to 4.94*10^-324 to make
|
|
164
|
+ ;; sure they return 0 or least-positive-double-float
|
|
165
|
+ (let ((expo (expt 10 -324)))
|
|
166
|
+ ;; 247/100*10^-45 is just under halfway between 0 and least-positive,
|
|
167
|
+ ;; so the answer is 0.
|
|
168
|
+ (assert-equal 0d0 (kernel::float-ratio-float (* 247/100 expo) 'double-float))
|
|
169
|
+
|
|
170
|
+ ;; These are all more than half way to
|
|
171
|
+ ;; least-positive-double-float, so they should return that.
|
|
172
|
+ (assert-equal least-positive-double-float
|
|
173
|
+ (kernel::float-ratio-float (* 248/100 expo) 'double-float))
|
|
174
|
+ (assert-equal least-positive-double-float
|
|
175
|
+ (kernel::float-ratio-float (* 4 expo) 'double-float))
|
|
176
|
+ (assert-equal least-positive-double-float
|
|
177
|
+ (kernel::float-ratio-float (* 494/100 expo) 'double-float))
|
|
178
|
+ (assert-equal least-positive-double-float
|
|
179
|
+ (kernel::float-ratio-float (* 988/100 expo) 'double-float))))
|
|
180
|
+ |