Name

round

Synopsis

round(x,n=0)

Returns a float whose value is number x rounded to n digits after the decimal point (i.e., the multiple of 10**- n that is closest to x). When two such multiples are equally close to x, round returns the one that is farther from 0. Since today’s computers represent floating-point numbers in binary, not in decimal, most of round’s results are not exact.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.