PEP0238 lament
Tim Peters
tim.one at home.com
Mon Jul 23 21:13:05 EDT 2001
[Tim]
> Why is that? It's because unlike any other builtin arithmetic
> operation, "/" today can cause *catastrophic* loss of
> information silently, and in ordinary cases.
[Roy Smith]
> Surely assignment causes catastrophic loss of information, no? If I
> say "x = 4", havn't I lost the old value of x?
Possibly (you may have aliases for the same value -- I can't guess), but if
so that was either your intent or a logic error in your code.
> Multiplication by zero causes catastrophic loss of information too.
No. x*0 is exactly 0: the true result is the result you get. 3/4 is--
forgetting the conceits of computer numerics for a moment --exactly 0.75,
and sqrt(pi)**2 is exactly pi, and exp(log(1 + 1e-200))-1 is exactly 1e-200.
In the first case a result of 0 is 100% loss of the full truth (and so
"catastrophic" in this sense); in the second case 754 double arithmetic may
lose about 1 part in 2**53 of the full truth (and so is an insignificant
loss of information for most applications); while in the last case 754
double arithmetic will return 0, again a 100% loss of information (not
academic: that kind of expression with small |x| is important in financial
models).
> Should we redefine how those operations work too?
Sounds even sillier to me than it did to you, you know.
More information about the Python-list
mailing list