Available in all subroutines.
x to the nearest integer, with ties rounding away from zero
(also known as commercial rounding).
math.NAN, a NaN will be returned.
x is integral, ±0,
x itself is returned.
Otherwise, the rounded value of
x is returned.
Try it out
math.round 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.
Add time zone offset to requests
Divide the world into time bands of custom size and forward time zone data to your origin server.
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.