diff -r e83292eea636 -r b05cc09c455e Number.st --- a/Number.st Fri Nov 22 01:49:39 2019 +0100 +++ b/Number.st Fri Nov 22 01:50:55 2019 +0100 @@ -1002,6 +1002,14 @@ "Created: / 16-06-2017 / 11:00:38 / cg" ! +ln2 + "return ln(2) in my representation (and accuracy)." + + ^ self subclassResponsibility + + +! + phi "return Phi in my representation (and accuracy)." @@ -2147,6 +2155,32 @@ "Modified: / 05-07-2017 / 17:23:06 / cg" ! +log2 + "return log base-2 of the receiver. + Raises an exception, if the receiver is less or equal to zero. + Here, fallback to the general logarithm code." + + (self isLimitedPrecisionReal not + or:[self generality < 1.0 generality]) ifTrue:[ + |f| + + (f := self asLongFloat) isFinite ifTrue:[ + ^ f log2. + ]. + ]. + ^ self ln / self class ln2 + + " + 2.0 log2 + 4.0 log2 + (2.0 raisedTo:100.0) log2 + (10 raisedTo:1000) log2 + (10 raisedTo:2000) log2 + (10 raisedTo:4000) log2 + (10 raisedTo:8000) log2 + " +! + log:aNumber "return log base aNumber of the receiver. This will usually return a float value"