math.round
Available inall subroutines.
Rounds x
to the nearest integer, with ties rounding away from zero
(also known as commercial rounding).
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.round
is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.
Click RUN on a sample below 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.