File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 9494 machine
9595 dump-file))
9696
97+ (define (bigfloat->readable-string x)
98+ (define real (bigfloat->real x)) ; Exact rational unless inf/nan
99+ (define float (real->double-flonum real))
100+ (if (= real float)
101+ (format "#i~a " float) ; The #i explicitly means nearest float
102+ (number->string real))) ; Backup is print as rational
103+
97104;; Runs a Rival machine on an input point.
98105(define (real-apply compiler pt [hint #f ])
99106 (match-define (real-compiler _ vars var-reprs _ _ machine dump-file) compiler)
104111 [repr (in-vector var-reprs)])
105112 ((representation-repr->bf repr) val)))
106113 (when dump-file
107- (define args (map bigfloat->rational (vector->list pt*)))
108- ;; convert to rational, because Rival reads as exact
109- (pretty-print `(eval f ,@args) dump-file 1 ))
114+ (define args (map bigfloat->readable-string (vector->list pt*)))
115+ (fprintf dump-file "(eval f ~a)\n " (string-join args " " )))
110116 (define-values (status value)
111117 (with-handlers ([exn:rival:invalid? (lambda (e) (values 'invalid #f ))]
112118 [exn:rival:unsamplable? (lambda (e) (values 'exit #f ))])
136142 (timeline-push!/unsafe 'outcomes
137143 (- (current-inexact-milliseconds) start)
138144 (rival-profile machine 'iterations )
139- (~a status)
145+ (symbol->string status)
140146 1 )
141147 (values status value))
142148
You can’t perform that action at this time.
0 commit comments