* Added log.
This commit is contained in:
parent
d88126aea1
commit
a596550e97
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -83,7 +83,7 @@
|
||||||
(export + - * / zero? = < <= > >= add1 sub1 quotient remainder
|
(export + - * / zero? = < <= > >= add1 sub1 quotient remainder
|
||||||
positive? expt gcd lcm numerator denominator exact-integer-sqrt
|
positive? expt gcd lcm numerator denominator exact-integer-sqrt
|
||||||
quotient+remainder number->string string->number max
|
quotient+remainder number->string string->number max
|
||||||
exact->inexact floor ceiling)
|
exact->inexact floor ceiling log)
|
||||||
(import
|
(import
|
||||||
(ikarus system $fx)
|
(ikarus system $fx)
|
||||||
(ikarus system $ratnums)
|
(ikarus system $ratnums)
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
(except (ikarus) + - * / zero? = < <= > >= add1 sub1 quotient
|
(except (ikarus) + - * / zero? = < <= > >= add1 sub1 quotient
|
||||||
remainder quotient+remainder number->string positive?
|
remainder quotient+remainder number->string positive?
|
||||||
string->number expt gcd lcm numerator denominator
|
string->number expt gcd lcm numerator denominator
|
||||||
exact->inexact floor ceiling
|
exact->inexact floor ceiling log
|
||||||
exact-integer-sqrt max))
|
exact-integer-sqrt max))
|
||||||
|
|
||||||
(define (fixnum->flonum x)
|
(define (fixnum->flonum x)
|
||||||
|
@ -1177,6 +1177,22 @@
|
||||||
[else (error 'ceiling "~s is not a number" x)]))
|
[else (error 'ceiling "~s is not a number" x)]))
|
||||||
|
|
||||||
|
|
||||||
|
(define log
|
||||||
|
(lambda (x)
|
||||||
|
(cond
|
||||||
|
[(fixnum? x)
|
||||||
|
(cond
|
||||||
|
[($fx= x 1) 0]
|
||||||
|
[($fx= x 0) (error 'log "undefined around 0")]
|
||||||
|
[($fx> x 0) (foreign-call "ikrt_fx_log" x)]
|
||||||
|
[else (error 'log "negative argument ~s" x)])]
|
||||||
|
[(flonum? x)
|
||||||
|
(cond
|
||||||
|
[(>= x 0) (foreign-call "ikrt_fl_log" x)]
|
||||||
|
[else (error 'log "negative argument ~s" x)])]
|
||||||
|
[(bignum? x) (log (exact->inexact x))]
|
||||||
|
[(ratnum? x) (- (log (numerator x)) (log (denominator x)))]
|
||||||
|
[else (error 'log "~s is not a number" x)])))
|
||||||
|
|
||||||
(define string->number
|
(define string->number
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
|
|
|
@ -393,6 +393,7 @@
|
||||||
[gcd i r]
|
[gcd i r]
|
||||||
[lcm i r]
|
[lcm i r]
|
||||||
[max i r]
|
[max i r]
|
||||||
|
[log i r]
|
||||||
[numerator i r]
|
[numerator i r]
|
||||||
[denominator i r]
|
[denominator i r]
|
||||||
[floor i r]
|
[floor i r]
|
||||||
|
|
Loading…
Reference in New Issue