Rounding¶
The rite.numeric.rounding submodule includes helpers for rounding values, computing floors and ceilings, and truncating.
Rounding Module¶
Numeric rounding utilities.
This submodule provides utilities for rounding operations like round, floor, ceil, and truncate.
Examples¶
from rite.numeric.rounding import ( ... rounding_round, ... rounding_floor ... ) rounding_round(3.14159, 2) 3.14 rounding_floor(3.9) 3
Modules¶
rounding_ceil
¶
rounding_floor
¶
rounding_round
¶
Round Function¶
Round number to specified decimal places.
Examples¶
from rite.numeric.rounding import rounding_round rounding_round(3.14159, 2) 3.14
Functions¶
rounding_round(value: float, decimals: int = 0) -> float
¶
Round number to specified decimal places.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Number to round. |
required |
decimals
|
int
|
Number of decimal places. |
0
|
Returns:
| Type | Description |
|---|---|
float
|
Rounded value. |
Examples:
>>> rounding_round(3.14159, 2)
3.14
>>> rounding_round(3.5)
4.0
>>> rounding_round(123.456, 1)
123.5
Notes
Uses banker's rounding (round half to even).
options: show_root_heading: true show_source: false heading_level: 2