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

Version Path
decidim-admin-0.19.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.17.2 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.18.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.17.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.16.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.17.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.16.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.15.2 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.15.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.15.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.14.4 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.14.3 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.14.2 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.14.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.13.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.12.2 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.13.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.12.1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.13.0.pre1 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss
decidim-admin-0.12.0 app/assets/stylesheets/decidim/admin/vendor/mathsass/functions/_log.scss