Sass in the Real World: book 2 of 4

Number Functions

Function defintion Function description
percentage($number) This will take a number which should be unitless and converts it into a precentage value. If you are dividing two numbers both of those numbers have to either be unitless or with a unit.
Example:
percentage(0.625); //62.5%
percentage(50px/100px); //50%
round($number) Rounds the number to the nearest whole number. This function will round up if 0.5 or above and round down if 0.4 or below. If you want more control over the direction use ciel or floor functions.
Example:
round(10.5); //11
round(10.3); //10
ceil($number) This function will always round up to the closest whole number.
Example:
ciel(10.25); //11
ciel(10.89); //11
floor($number) This function will always round down to the closest whole number.
Example:
floor(10.25); //10
floor(10.89); //10
abs($number) This function will return the absolute value of a number.
Example:
abs(10px); //10px
abs(-10px); //10px
min($numbers…) This function will return the smallest value of a series of numbers.
Example:
min(0.625em, 0.75em, 1em); //0.625em
max($numbers…) This function will return the largest value of a series of numbers.
Example:
max(0.625em, 0.75em, 1em); //1em