Re: [Sbcl-commits] master: Correctly round floats converted from ratios
Stas Boukarev <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.devel |
|---|---|
| Message-ID | <CAF63=102kKwjG2y3_JineOd3SVytt=bx=0gOB4tzYSNvtwz8oA@mail.gmail.com> |
On Wed, Jan 28, 2026 at 12:10 AM Christophe Rhodes via Sbcl-devel <[email protected]> wrote: > > stassats via Sbcl-commits <[email protected]> writes: > > > +(defun check-ratio-to-float (ratio type) > > + (declare (ratio ratio)) > > + (let* ((result (float ratio type)) > > + (new-ratio (rational result))) > > + (multiple-value-bind (sig exp sign) (integer-decode-float result) > > + (let* ((prev-float (scale-float (float (* sign (1- sig)) type) exp)) > > I think this line is off-by-one if the float in question is a > non-denormal and exactly at a power-of-two boundary, where the > resolution is twice as fine below the float as above the float. Corrected. > Also, how should conversion to float behave above > most-positive-fooble-float? Is there an implicit interval above the > maximum where we convert down and don't error, or does anything above > the rational value of the most-positive float signal overflow? The float-ratio functions call scale-float, which then decides whether to overflow or not. _______________________________________________ Sbcl-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sbcl-devel