On Wed, May 12, 2010 at 11:44 AM, Stavros Macrakis
<macrakis at alum.mit.edu> wrote:
> On Tue, May 11, 2010 at 09:59, Robert Dodier <robert.dodier at gmail.com>
> wrote:
>>
>> ...There is a different interpretation of the float function, which
>> I think I would prefer, namely float(foo(x)) should return the
>> floating point number closest to the numerical value of foo(x).
>> ...
>> The latter is obviously more work
>
> That's an understatement! I suppose if we had arbitrary-precision interval
> arithmetic (which we don't) we could calculate foo(x) at ever increasing
> precisions until the interval was small enough (either 1e-16 relative error
> or 2e-323 absolute error near zero). But how often are such heroic measures
> really useful to the user?
Well, "return the floating point number closest to the numerical value"
is just the simplest, clearest thing I could think of ...
something like "return a floating point approximation to the numerical
value" leaves too much wiggle room, right? I could return 1.0 for
every positive value and say "Hey, at least I got the sign right."
Maybe there's a way to be more precise.
I'm not really stuck on the "closest float" idea; mostly I just want
to disconnect the specification of the float function from floating
point values in input variables. Propagating floats might or might
not be the best way to get to a final result which is a float.
FWIW
Robert Dodier