Changeset 25798 in project


Ignore:
Timestamp:
01/10/12 20:45:52 (9 years ago)
Author:
sjamaan
Message:

numbers: Check for finite numbers before trying to convert flonums to ratnums, so NaN doesn't get translated to 0.0 (reported by Felix, but with different symptoms so maybe not properly fixed yet)

Location:
release/4/numbers/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers.scm

    r25260 r25798  
    11561156    (FIX x)
    11571157    (FLO (cond
    1158           ((or (= x +inf) (= x -inf)) (bad-inexact 'inexact->exact x))
     1158          ((not (finite? x)) (bad-inexact 'inexact->exact x))
    11591159          ((%flo-integer? x) (%flo->integer x))
    11601160          (else (%flo->rat 'inexact->exact x))))
  • release/4/numbers/trunk/tests/numbers-test.scm

    r25181 r25798  
    400400
    401401 (test "inexact->exact" (string->number "2589569785738035/1125899906842624") (inexact->exact 2.3))
     402 (test-error "inexact->exact +inf" (inexact->exact +inf.0))
     403 (test-error "inexact->exact -inf" (inexact->exact -inf.0))
     404 (test-error "inexact->exact -NaN" (inexact->exact +nan.0))
    402405 (test "expt" 16 (expt 2 4))
    403406 (test-assert "expt" (show (expt 2 100)))
Note: See TracChangeset for help on using the changeset viewer.