Sha256: 2d046e7636a179e87a62b75ab20c6ff7bbdf115f2532192f1cc9b6059324d97f

Contents?: true

Size: 1.36 KB

Versions: 90

Compression:

Stored size: 1.36 KB

Contents

// https://gist.github.com/voxpelli/6304812

@function pi()
  @return 3.14159265359

@function gcd($a, $b)
  // From: http://rosettacode.org/wiki/Greatest_common_divisor#JavaScript
  @if ($b != 0)
    @return gcd($b, $a % $b)
  @else
    @return abs($a)

@function pow($base, $exponent, $prec: 12)
  // Handles decimal exponents by trying to convert them into a fraction and then use a nthRoot-algorithm for parts of the calculation
  @if (floor($exponent) != $exponent)
    $prec2 : pow(10, $prec)
    $exponent: round($exponent * $prec2)
    $denominator: gcd($exponent, $prec2)
    @return nthRoot(pow($base, $exponent / $denominator), $prec2 / $denominator, $prec)
  $value: $base
  @if $exponent > 1
    @for $i from 2 through $exponent
      $value: $value * $base
  @else if $exponent < 1
    @for $i from 0 through -$exponent
      $value: $value / $base
  @return $value

@function nthRoot($num, $n: 2, $prec: 12)
  // From: http://rosettacode.org/wiki/Nth_root#JavaScript
  $x: 1
  @for $i from 0 through $prec
    $x: 1 / $n * (($n - 1) * $x + ($num / pow($x, $n - 1)))
  @return $x

@function ratio_calculation($n1, $n2, $n3)
  @return ($n2 * $n3) / $n1

@function second_decimal_place_floor($num)
  @return floor($num * 10) / 10

@function second_decimal_place_ceil($num)
  @return ceil($num * 10) / 10

@function second_decimal_place_round($num)
  @return round($num * 10) / 10

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
oulu-0.19.1 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.19.0 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.5 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.4 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.3 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.2 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.1 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.18.0 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.9 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.8 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.7 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.6 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.4 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.3 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.2 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.1 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.17.0 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.16.9 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.16.8 app/assets/stylesheets/settings/functions/_math.sass
oulu-0.16.7 app/assets/stylesheets/settings/functions/_math.sass