# [plt-scheme] log

After playing a litle with procedure log i found:
(1) (log positive-exact-integer) never returns +inf.0 (although some time may be required, especially during compilation, for exponents beyond one million)
(2) (log positive-exact-rational) may return +inf.0, even when log does not return +inf.0 for larger exact integers.
(3) Therefore I use (let ((x (inexact->exact x))) (- (log (numerator x)) (log (denominator x)) for any real x.
(4) I ignore the fact that even the log may be too big for a floating point. Anyway, when that is the case log does not return before exhausting my patience, which is quite acceptible of course (I mean the not returning, not my impatience:)
Questions:
(1) is this a correct approach (i.e. may I assume that PLT scheme's log does not produce +inf.0 on very large exact integer numbers? (as long as the log does not exceed 1e234)
(2) is there somewhere a solidly based (integer-log positive-exact-integer-n) function that returns the greatest exact natural number p such that (expt e p)<=n?
(3) An absolute error less than a few units would not be a problem. I can always make a few steps up or down afterwards.
In fact I use base 10 logs, but thats only a matter of scaling.
I am speaking about Welcome to DrScheme, version 3.99.0.23-svn22apr2008 [3m].
Jos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080424/0a2e7195/attachment.html>