Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Sass Numeric Functions


Sass Numeric Functions

The numeric functions are used to manipulate numeric values.

The following table lists all numeric functions in Sass:

Function Description & Example
abs(number) Returns the absolute value of number.

Example:
abs(15)
Result: 15
abs(-15)
Result: 15
ceil(number) Rounds number up to the nearest integer.

Example:
ceil(15.20)
Result: 16
comparable(num1, num2) Returns whether num1 and num2 are comparable.

Example:
comparable(15px, 10px)
Result: true
comparable(20mm, 1cm)
Result: true
comparable(35px, 2em)
Result: false
floor(number) Rounds number down to the nearest integer.

Example:
floor(15.80)
Result: 15
max(number...) Returns the highest value of several numbers.

Example:
max(5, 7, 9, 0, -3, -7)
Result: 9
min(number...) Returns the lowest value of several numbers.

Example:
min(5, 7, 9, 0, -3, -7)
Result: -7
percentage(number) Converts number to a percentage (multiplies the number with 100).

Example:
percentage(1.2)
Result: 120
random() Returns a random number between 0 and 1.

Example:
random()
Result: 0.45673
random(number) Returns a random integer between 1 and number.

Example:
random(6)
Result: 4
round(number) Rounds number to the nearest integer.

Example:
round(15.20)
Result: 15
round(15.80)
Result: 16

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.