Created
August 21, 2011 16:29
-
-
Save scottkellum/1160816 to your computer and use it in GitHub Desktop.
Sassy exponents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sass exponent support | |
@function exponent($base, $exponent) | |
// reset value | |
$value: $base | |
// positive intergers get multiplied | |
@if $exponent > 1 | |
@for $i from 2 through $exponent | |
$value: $value * $base | |
// negitive 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great. I've used your exponent function in a recent gist of mine to calculate the fibonacci sequence and I wanted to thank you. https://gist.github.com/AlexGetty/8602586