float eval, a puzzle



>>>>> "Richard" == Richard Fateman <fateman at eecs.berkeley.edu> writes:

    Richard> 1-sqrt(2)*sin(atan(1));
    Richard> 1.0-sqrt(2.0)*sin(atan(1.0));
    Richard> 1.0-sqrt(2.0)*sin(atan(1));
    Richard> 1-sqrt(2)*sin(atan(1.0));

    Richard> All return different expressions.
    Richard> Hint: the first one is 0.

I've seen things like this before.  They all make sense if you think
that floats aren't contagious.  Hence, the third and fourth examples
make sense that sqrt(2) remains as is, even though it's multiplied by
a float.

There are many times I have wished floats to be more contagious so
that products and sums of floats and exact values would cause the
exact values to be evaluated as floats.

But I have become accustomed to doing float(%) to get everything into
a float.

Ray