math.floor

FLOATmath.floorFLOATx

Available in all subroutines.

Computes the largest integer value less than or equal to the given value. In other words, round x towards negative infinity.

For example, 2.2, 2.5, and 2.7 all floor to 2.0.

Return Value

If x is math.NAN, a NaN will be returned.

If x is integral, ±0, x itself is returned.

If x is math.POS_INFINITY or math.NEG_INFINITY, an infinity of the same sign is returned.

Otherwise, the rounded value of x is returned.

Try it out

math.floor is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Geofencing / geoblocking content by region

Group countries to cache content by custom regions or reject requests from some regions entirely.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.