Sass math Constants

Beginner
8 min read
Updated: Nov 2026
5 examples
Dart Sass 1.25+

Definition and Usage

The sass:math module ships seven read-only variables: math.$pi, math.$e, math.$epsilon, math.$max-number, math.$min-number, math.$max-safe-integer, and math.$min-safe-integer. All are unitless numbers.

Load them with @use "sass:math". math.$pi and math.$e arrived in Dart Sass 1.25+, alongside the rest of the math module.

Official values.

math.$pi is 3.1415926536 and math.$e is 2.7182818285. The safe-integer limits are 9007199254740991 and -9007199254740991.

Inside calculations.

Plain CSS calc(pi) and calc(e) also work—see calculations. Use math.$pi when you need the number in ordinary Sass math.

Read-only.

You cannot assign to a built-in constant. math.$pi: 3; is a compile error.

Syntax

SCSS
@use "sass:math";

math.$pi;                 // 3.1415926536
math.$e;                  // 2.7182818285
math.$epsilon;            // tiny; prints as 0
math.$max-number;         // largest Sass number (about 1.8e308)
math.$min-number;         // smallest positive number; prints as 0
math.$max-safe-integer;   // 9007199254740991
math.$min-safe-integer;   // -9007199254740991

// Circumference of a circle with radius 45
2 * math.$pi * 45;        // 282.7433388231

// Module API — prefer math.$pi after @use "sass:math"

Pattern: @use "sass:math" → read the constant → combine it with math.pow(), math.log(), or trig functions.

The Seven Constants

What each constant is for:

ConstantValueTypical use
math.$pi3.1415926536Circles, angles, trigonometry
math.$e2.7182818285Natural growth, math.log / math.pow
math.$epsilonAbout 0.00000000001; prints 0The gap below which Sass treats numbers as equal
math.$max-numberAbout 1.8 × 10³⁰⁸Sentinel for finding a minimum
math.$min-numberSmallest positive number; prints 0Lower bound sentinel
math.$max-safe-integer9007199254740991Largest integer Sass can count exactly
math.$min-safe-integer-9007199254740991Smallest integer Sass can count exactly
Precision.

Sass prints numbers with ten decimal places, so very small constants such as $epsilon and $min-number appear as 0.

SCSS Examples

Examples use Dart Sass with @use "sass:math". Open View Compiled CSS to see each constant in context.

Example 1 — Circle Math with math.$pi

Size an SVG progress ring from its radius.

SCSS
@use "sass:math";

$radius: 45;

.ring {
  stroke-dasharray: 2 * math.$pi * $radius;
  --turn: #{math.$pi * 2};
  --area: #{math.$pi * math.pow($radius, 2)};
}

How It Works

  1. 2 * math.$pi * 45 is the circumference, 282.7433388231.
  2. math.$pi * 2 is a full turn in radians.
  3. math.pow($radius, 2) squares the radius for the area.
  4. Everything stays unitless, so you can attach a unit later.

Example 2 — Natural Growth with math.$e

Pair math.$e with math.pow() and math.log().

SCSS
@use "sass:math";

.growth {
  --e: #{math.$e};
  --e-squared: #{math.pow(math.$e, 2)};
  --ln-e: #{math.log(math.$e)};
}

How It Works

  1. math.$e is Euler’s number.
  2. math.pow(math.$e, 2) raises it to the second power.
  3. math.log(math.$e) is the natural log, which returns 1.
  4. Useful for exponential easing and decay curves.

Example 3 — Safe Integer Limits

Past the limit, whole numbers stop being exact.

SCSS
@use "sass:math";

.integers {
  --max: #{math.$max-safe-integer};
  --min: #{math.$min-safe-integer};
  --plus-one: #{math.$max-safe-integer + 1};
  --plus-two: #{math.$max-safe-integer + 2};
}

How It Works

  1. $max-safe-integer is 9007199254740991.
  2. $min-safe-integer is the same value, negated.
  3. Adding one still works: 9007199254740992.
  4. Adding two lands on the same number—precision has run out.

Example 4 — $max-number as a Sentinel

Start from the biggest number, then shrink it with math.min().

SCSS
@use "sass:math";

$smallest: math.$max-number;

@each $n in 12, 7, 30 {
  $smallest: math.min($smallest, $n);
}

.limits {
  --smallest: #{$smallest};
  --is-huge: #{math.$max-number > 1000000};
  --epsilon: #{math.$epsilon};
  --min-number: #{math.$min-number};
}

How It Works

  1. math.$max-number is bigger than any value in the list.
  2. math.min keeps the smallest item so far, ending at 7.
  3. $epsilon and $min-number are so small they print as 0.
  4. Compare large values with normal operators, as with --is-huge.

Example 5 — Constants Cannot Be Changed

Assigning to a built-in variable is an error.

SCSS
@use "sass:math";

math.$pi: 3;

How It Works

  1. math.$pi: 3; tries to overwrite a built-in variable.
  2. Sass refuses and stops compilation.
  3. Copy it instead: $my-pi: math.$pi;.
  4. Keep custom values in your own variables.

Edge Cases & Pitfalls

Most constant surprises come from precision, units, and forgetting the module namespace.

zero

Tiny constants print as 0

$epsilon and $min-number are below Sass’s ten-decimal output, so they print and compare like 0.

unit

Constants are unitless

Attach a unit after the math: math.$pi * 10px. Angle functions expect rad or deg—see math.sin().

safe

Integers past the safe limit lose precision

Adding 1 and 2 to $max-safe-integer can give the same result.

module

Needs the namespace

Write math.$pi after @use "sass:math". A bare $pi is not defined.

Sass Support

Part of the sass:math module.

APIStatus
math.$pi, math.$eDart Sass 1.25+ via @use "sass:math"
$epsilon, $max-number, $min-number, safe-integer limitsCurrent Dart Sass math module
TypeUnitless number, read-only
LibSass / Ruby SassNo modern sass:math constants

Compile with the Dart Sass CLI.

Key Takeaways

  • Seven read-only constants live in sass:math.
  • math.$pi and math.$e are the everyday ones.
  • $epsilon and $min-number print as 0 at Sass’s precision.
  • Constants are unitless—add units after the math.

One line: after @use "sass:math", read math.$pi, math.$e, and the limit constants as unitless numbers.

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:math"
2. Read math.$pi or math.$e directly
3. Add units after the math (math.$pi * 10px)
4. Use math.$max-number as a minimum-search sentinel
5. Never assign to a math constant

Frequently Asked Questions

The sass:math module provides math.$pi, math.$e, math.$epsilon, math.$max-number, math.$min-number, math.$max-safe-integer, and math.$min-safe-integer.
math.$pi is 3.1415926536 and math.$e is 2.7182818285, both unitless numbers.
They are far smaller than the ten decimal places Sass prints, so they appear as 0 even though they are tiny positive numbers.
No. Assigning to math.$pi or any built-in variable is a compile error. Copy it into your own variable instead.
math.$max-safe-integer is 9007199254740991 and math.$min-safe-integer is -9007199254740991. Beyond them, whole numbers are no longer exact.
calc(pi) is the CSS calculation constant. math.$pi is a Sass variable you can use in ordinary Sass math outside calculations.

Next: Sass math.acos()

Compute the arccosine of a number in degrees.

math.acos() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful