From: Morton Goldberg Date: 2007-02-08T09:08:38+09:00 Subject: Re: Adding Math.log2 and Math.logn to the core library. On Feb 7, 2007, at 6:20 PM, Phrogz wrote: > On Feb 7, 2:57 pm, Keynan Pratt wrote: >> perhaps it would be wiser to add >> >> def log_(n, x) >> log x / log n >> end >> >> so that any log base may be used. > > Other than changing the order of parameters (which I'm personally > ambivalent about, and would certainly accept this order if that's how > most other libraries do it) and changing the name to end in an > underscore (which I'm not sure I like), what are you proposing that I > wasn't? Simply that we ONLY add the log-base-n capability that I > described, without a specific method for log-base-2 calculations? Well, I can find examples with the base first or second. Perhaps for Ruby it would most idiomatic to define log as follows def Math.log(x, b=Math::E); ... ; end as the core method with log10 and log2 handled (for performance) as special cases within this method. Given that, I would still want Math to implement log10 and log2 methods for convenience. If we were to go with a two argument log, I prefer the "logb" name to "logn" because "n" suggests an integer and the base doesn't have to be an integer (e.g., it could be Math::E). Regards, Morton