Sha256: 5b343b77c03e79623edb411bdd625d93397473bc5289bacb0b102603fa029de8
Contents?: true
Size: 708 Bytes
Versions: 102
Compression:
Stored size: 708 Bytes
Contents
// Returns the natural logarithm of a number. // @param {Number} $x // @param {Number} $b The base number // @example // log(2) // 0.69315 // log(10) // 2.30259 // log(2, 10) // 0.30103 @function log ($x, $b: null) { @if $b == null { @return _log($x); } @else { @return _log($x) / _log($b); } } @function _log ($x) { @if $x <= 0 { @return 0 / 0; } $k: nth(frexp($x / $SQRT2), 2); $x: $x / ldexp(1, $k); $x: ($x - 1) / ($x + 1); $x2: $x * $x; $i: 1; $s: $x; $sp: null; @while $sp != $s { $x: $x * $x2; $i: $i + 2; $sp: $s; $s: $s + $x / $i; } @return $LN2 * $k + 2 * $s; }
Version data entries
102 entries across 102 versions & 2 rubygems