Sha256: 5c8980dda64bba2af6549a435bd5e3d344c109f2099460d19c317e50186cf41b
Contents?: true
Size: 717 Bytes
Versions: 31
Compression:
Stored size: 717 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 @use "sass:math"; @function log ($x, $b: null){ @if $b == null{ @return _log($x); } @else{ @return math.div(_log($x), _log($b)); } } @function _log ($x){ @if $x <= 0{ @return math.div(0, 0); } $k: nth(frexp(math.div($x, $SQRT2)), 2); $x: math.div($x, ldexp(1, $k)); $x: math.div($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 + math.div($x, $i); } @return $LN2 * $k + 2 * $s; }
Version data entries
31 entries across 31 versions & 1 rubygems