Skip to content

Rounding Mode

A string that determines how a float is rounded off.

Values

Value Description
up Rounds the value away from zero, where the digit prior to a non-zero value is incremented.
down Rounds the value towards zero, where the float is truncated to the specified decimal places.
ceiling Rounds the value towards positive infinity. If the value is positive, it behaves like up and if it's negative, it behaves like down.
floor Rounds the value towards negative infinity. If the value is positive, it behaves like down and if it's negative, it behaves like up.
half_up Rounds the value towards the "nearest neighbor" unless both neighbors are equidistant, in which case, it'll be rounded up.
Behaves like up if the digit is $\gtrapprox 0.5$, otherwise, it behaves like down.
half_down Rounds the value towards the "nearest neighbor" unless both neighbors are equidistant, in which case, it'll be rounded down.
Behaves like up if the digit is $\gt 0.5$, otherwise, it behaves like down.
half_even Rounds the value towards the "nearest neighbor" unless both neighbors are equidistant, in which case, it'll round towards the even neighbor.
Behaves like half_up if the digit to the left is odd, otherwise, it behaves like half_down if it's even.

Examples

Input Rounded off to 1 digit
$3.54$ $4$
$2.87$ $3$
$1.34$ $2$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-2$
$-2.34$ $-3$
$-3.86$ $-4$
Input Rounded off to 1 digit
$3.54$ $3$
$2.87$ $2$
$1.34$ $1$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-1$
$-2.34$ $-2$
$-3.86$ $-3$
Input Rounded off to 1 digit
$3.54$ $4$
$2.87$ $3$
$1.34$ $2$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-1$
$-2.34$ $-2$
$-3.86$ $-3$
Input Rounded off to 1 digit
$3.54$ $3$
$2.87$ $2$
$1.34$ $1$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-2$
$-2.34$ $-3$
$-3.86$ $-4$
Input Rounded off to 1 digit
$3.54$ $4$
$2.87$ $3$
$1.34$ $1$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-1$
$-2.34$ $-2$
$-3.86$ $-4$
Input Rounded off to 1 digit
$3.54$ $4$
$2.87$ $3$
$1.34$ $1$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-1$
$-2.34$ $-2$
$-3.86$ $-4$
Input Rounded off to 1 digit
$3.54$ $4$
$2.87$ $3$
$1.34$ $1$
$1.0$ $1$
$-1.0$ $-1$
$-1.23$ $-1$
$-2.34$ $-2$
$-3.86$ $-4$