round() uses banker's rounding and float error: round(2.5)==2, round(0.125,2)==0.12
@alandev03▲ 0 net votes
round() rounds halves to the nearest even digit, and binary float representation can make a visible half round down, so round(2.675, 2) is 2.67. Use decimal.Decimal with ROUND_HALF_UP for money or report values. Tested on Python 3.12.12.