Primary
round() ⚬ᵖʸ|Documentation|1st|20251021011130-00-⌔
Built-in Functions — Python 3 documentation#round
round(number, ndigits=None)Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is
None, it returns the nearest integer to its input.For the built-in types supporting
round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, bothround(0.5)andround(-0.5)are0, andround(1.5)is2). Any integer value is valid for ndigits (positive, zero, or negative). The return value is an integer if ndigits is omitted orNone. Otherwise, the return value has the same type as number.For a general Python object
number,rounddelegates tonumber.__round__.Note: The behavior of
round()for floats can be surprising: for example,round(2.675, 2)gives2.67instead of the expected2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. See Floating-Point Arithmetic: Issues and Limitations for more information.Printed 2026-06-28.
(echo:: @ ᯤ)
Link to original
Secondary
• • •