Sass Numeric Functions
Sass numeric functions are used to handle numeric values.
The following table lists Sass numeric functions:
| Function | Description & Example |
|---|---|
| abs(number) | Returns the absolute value of a number. Example: abs(15) Result: 15 abs(-15) Result: 15 |
| ceil(number) | Round up Example: ceil(15.20) Result: 16 |
| comparable(num1, num2) | Returns a boolean value indicating whethernum1andnum2it can be compared Example: comparable(15px, 10px) Result: true comparable(20mm, 1cm) Result: true comparable(35px, 2em) Result: false |
| floor(number) | Round down Example: floor(15.80) Result: 15 |
| max(number...) | Returns the maximum value Example: max(5, 7, 9, 0, -3, -7) Result: 9 |
| min(number...) | Returns the minimum value Example: min(5, 7, 9, 0, -3, -7) Result: -7 |
| percentage(number) | Converts a number to a percentage expression. Example: percentage(1.2) Result: 120 |
| random() | Returns a decimal between 0 and 1, Example: random() Result: 0.45673 |
| random(number) | Returns an integer between 1 and number, including 1 and limit. Example: random(6) Result: 4 |
| round(number) | Returns the nearest integer to the number, rounded half up. Example: round(15.20) Result: 15 round(15.80) Result: 16 |
Other Extensions
Sass Functions