Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pow() when available #4

Closed
KittyGiraudel opened this issue Oct 16, 2014 · 0 comments
Closed

Use pow() when available #4

KittyGiraudel opened this issue Oct 16, 2014 · 0 comments
Assignees

Comments

@KittyGiraudel
Copy link

You could make your exponent() function use pow for Compass, Sassy-Math or whatever when available.

@function exponent($base, $exponent) {
    @if pow(2, 2) == 4 {
        @return pow($base, $exponent);
    }

    // Resets value.
    $value: $base;
    // Positive intergers get multiplied.
    @if $exponent > 1 {
        @for $i from 2 through $exponent {
            $value: $value * $base; } }
    // Negatives intergers get divided. A number divided by itself is 1.
    @if $exponent < 1 {
        @for $i from 0 through -$exponent {
            $value: $value / $base; } }
    // Return the last value written.
    @return $value;
}
@hiulit hiulit closed this as completed in 43023a9 Oct 16, 2014
@hiulit hiulit self-assigned this Oct 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants