[python] round v python 3.0

Stepan Wagner stepan.wagner na gmail.com
Neděle Únor 1 16:28:07 CET 2009


citace ze stranky http://en.wikipedia.org/wiki/Rounding#Round-to-even_method

"""When dealing with large sets of scientific or statistical data,
where trends are important, traditional rounding on average biases the
data upwards slightly. Over a large set of data, or when many
subsequent rounding operations are performed as in digital signal
processing, the round-to-even rule tends to reduce the total rounding
error, with (on average) an equal portion of numbers rounding up as
rounding down. This generally reduces upwards skewing of the
result."""

Stepan

2009/2/1 Pavel Kosina <geon na post.cz>:
> Nevíte někdo, *proč* v Python 3.0 platí:
>
>>>> round(0.5)
> 0
>>>> round (1.5)
> 2
>>>> round (2.5)
> 2
>>>> round (3.5)
> 4
>
> Jo, máme to napsané v manuálu, že to takhle je
> http://docs.python.org/3.0/library/functions.html#round, ale mě zajímá proč
> to je takto, a ne podle toho, jak se to učí v 5. třídě, tedy že od pětky
> včetně nahoru se zaokrouhluje nahoru vždy, a ne jen někdy .....
>
> Díky
>
> --
> geon
> Pavel Kosina
>
> _______________________________________________
> Python mailing list
> Python na py.cz
> http://www.py.cz/mailman/listinfo/python
>


Další informace o konferenci Python