Skip to content

Commit a2228cc

Browse files
committed
Faster near-zero test?
1 parent 8bd9480 commit a2228cc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mpfr.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
bfodd?
163163
bfcopy
164164
bfstep
165+
bigfloat->flonum
165166
bigfloats-between
166167
bfprev
167168
bfnext

utils.rkt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#lang racket/base
22

3-
(require "eval/machine.rkt")
4-
(require math/bigfloat
5-
math/flonum)
3+
(require "mpfr.rkt"
4+
"eval/machine.rkt")
5+
(require math/flonum)
66
(provide flonum-discretization
77
boolean-discretization
88
bf-discretization)
@@ -11,12 +11,14 @@
1111

1212
(define boolean-discretization (discretization 53 values (lambda (x y) (if (eq? x y) 0 2))))
1313

14+
(define min-exponent (mpfr-exp (bfnext 0.bf)))
15+
1416
(define (bf-discretization [precision #f])
1517
(define n (or precision (bf-precision)))
1618
(discretization n
1719
(lambda (x)
1820
(parameterize ([bf-precision n])
19-
(if (equal? (bigfloats-between 0.bf x) 1)
21+
(if (and (= (mpfr-exp x) min-exponent) (equal? (bigfloats-between 0.bf x) 1))
2022
(bf 0)
2123
(bfcopy x))))
2224
(lambda (x y)

0 commit comments

Comments
 (0)