Changeset 26305 in project


Ignore:
Timestamp:
04/01/12 15:14:34 (9 years ago)
Author:
sjamaan
Message:

numbers: Improved error messages for expt and log

File:
1 edited

Legend:

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

    r26304 r26305  
    104104(define (bad-exact loc x) (##sys#signal-hook #:type-error loc "bad argument type - exact number cannot be represented by a flonum" x))
    105105(define (log0 loc x) (##sys#signal-hook #:arithmetic-error loc "log of exact 0 is undefined" x))
     106(define (expt0 loc x y) (##sys#signal-hook #:arithmetic-error loc "exponent of exact 0 with complex argument is undefined" x y))
    106107(define (div/0 loc x y) (##sys#signal-hook #:arithmetic-error loc "division by zero" x y))
    107108
     
    13791380      (log0 'log x))
    13801381     ((eq? type NONE)
    1381       (bad-number 'exp x))
     1382      (bad-number 'log x))
    13821383     (else                             ; Simple real number case
    13831384      (##core#inline_allocate ("C_a_i_log" 4) (%exact->inexact x))))))
     
    15551556
    15561557(define (expt a b)
    1557   (define (slow-expt a b) (%exp (%* b (%log a))))
     1558  (define (slow-expt a b)
     1559    (if (eq? 0 a)
     1560        (expt0 'expt a b)
     1561        (%exp (%* b (%log a)))))
    15581562  (let ((ta (%check-number a))
    15591563        (tb (%check-number b)) )
Note: See TracChangeset for help on using the changeset viewer.