--- a/ShortFloat.st Mon Jul 03 15:18:59 2017 +0200
+++ b/ShortFloat.st Mon Jul 03 15:22:07 2017 +0200
@@ -1285,6 +1285,66 @@
"
!
+ln
+ "return the natural logarithm of the receiver.
+ Raises an exception, if the receiver is less or equal to zero."
+
+%{ /* NOCONTEXT */
+#ifndef __SCHTEAM__
+ float val, rslt;
+ OBJ newFloat;
+
+ val = __shortFloatVal(self);
+
+ /*
+ * to suppress the warnBox opened by win32
+ * to avoid returning -INF from some unix math libs (__osx__)
+ */
+ if (val > 0.0) {
+ __threadErrno = 0;
+# ifdef NO_LOGF
+ {
+ double dRslt = log((double)val);
+ rslt = (float)dRslt;
+ }
+# else
+ rslt = logf(val);
+# endif
+ if (! isnanf(rslt)) /* Currently all our systems support isnan() */
+ {
+ if (__threadErrno == 0) {
+ __qMKSFLOAT(newFloat, rslt);
+ RETURN ( newFloat );
+ }
+ }
+ }
+#endif
+%}.
+ "
+ an invalid value for logarithm
+ "
+ ^ self class
+ raise:#domainErrorSignal
+ receiver:self
+ selector:#ln
+ arguments:#()
+ errorString:'bad receiver in log10 (not strictly positive)'
+
+ "
+ 10 asFloat ln 2.30258509299405
+ 10 asShortFloat ln 2.302585
+ 10 asLongFloat ln 2.302585092994045684
+ 10 asQDouble ln 2.30258509299404568402
+
+ 50 asFloat ln 3.91202300542815
+ 50 asShortFloat ln 3.912023
+ 50 asLongFloat ln 3.912023005428146059
+ 50 asQDouble ln 3.91202300542814605862
+ "
+
+ "Created: / 03-07-2017 / 15:20:07 / cg"
+!
+
log10
"return the base-10 logarithm of the receiver.
Raises an exception, if the receiver is less or equal to zero."