PEP proposal for round(x,n) enhancement
Markus Schaber
markus at schabi.de
Wed Sep 12 14:53:33 EDT 2001
Hi,
Christopher Smith <csmith at blakeschool.org> schrub:
> This is a totally different issue. The proposal is not concerned with
> how numbers are represented internally, just with how they are
> printed. Presumably that is one thing that the round(x,n) function is
> for--it let's
> me through away information that I don't want. What is inconvenient,
> as someone else noted--is that while the magnitudes of numbers can
> vary wildy (especially in the sciences) the number of digits past the
> first non-zero digit often do not...in general, regardless of the
> magnitude of the number, I would often not want more than the first 3
> digits.
The problem is that you can't store this information in a floating
point number. I just tried the following:
>>> 0.2
0.20000000000000001
This, I give the number with 1 significant digit, and end up having
displayed 17 "significant" digits.
So you may only round (or whatever we call it) to powers of two, but
not to powers of 10 (digits) without having rationals or decimals.
--
"The strength of the Constitution lies entirely in the determination of
each citizen to defend it. Only if every single citizen feels duty
bound to do his share in this defense are the constitutional rights
secure." -- Albert Einstein
More information about the Python-list
mailing list