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