|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
rounding
Python uses the so-called banker's rounding: when a number is exactly halfway between two integers (i.e. the end is Nim uses the traditional rounding, as we learned it in the primary school. Another difference: when echo int(round(1.5)) # 2 (int) What is banker's rounding good for?I asked an LLM and it gave me the following acceptable answer: "The purpose of banker's rounding (also known as "round half to even") is to avoid systematic bias. With traditional rounding (always rounding 0.5 up), if you round many numbers, the results are systematically biased upward — because numbers exactly halfway are always rounded up. With large datasets this accumulates and causes a significant error. With banker's rounding, halfway numbers are rounded to the nearest even integer:
This way the roundings up and down statistically cancel each other out, and with large datasets the sum/average remains much more accurate. It is especially important in financial calculations, which is where the name comes from — if a bank rounds millions of transactions per day, with the traditional method it would systematically account for more money than it should." (Claude AI) |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||