[racket] Multiplying by 0

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Mon Feb 14 15:47:42 EST 2011

On 2/14/11 3:44 PM, Stephen Bloch wrote:
> On Feb 14, 2011, at 3:26 PM, David Van Horn wrote:
>> On 2/14/11 3:14 PM, Sam Tobin-Hochstadt wrote:
>>> No, it's not a bug.  Since 1e100 is an inexact number, there's
>>> uncertainty about the minimum of those two numbers, and the result is
>>> therefore inexact.
>> I would've expected min to return a number that is `eq?' to one of its arguments.
>> In other words, what is wrong with this definition of `min'?
>> (define (min n1 n2)
>>   (cond [(<= n1 n2) n1]
>>         [else n2]))
> What's wrong with this is that, mathematically, since 1e100 is inexact, we're not CERTAIN it's>= 0, so the "proper" answer to (<= n1 n2) is not true but rather almost-certainly-true.  (An "inexact Boolean", if you will....)
> When you define the function as above, the "<=" takes its best guess as to which number is really smaller and pretends that the answer is certain.

Then what is the correct definition?


Posted on the users mailing list.