[racket] Multiplying by 0

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

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]))

(min 0 1e100) ;=> 0

David


> On Mon, Feb 14, 2011 at 3:09 PM, Gregory Woodhouse<gregwoodhouse at me.com>  wrote:
>> Oops... Now that has to qualify as a bug.
>>
>> On Feb 14, 2011, at 11:58 AM, Joe Marshall wrote:
>>
>>> 2011/2/13 José Lopes<jose.lopes at ist.utl.pt>:
>>>> I understand. However, not only that disregards type promotion but also is
>>>> incoherent since (+ 0 0.0) evaluates to 0.0.
>>>
>>> Worse:
>>> (min 0 1e100) =>  0.0
>>>
>>> --
>>> ~jrm
>>
>> _________________________________________________
>>   For list-related administrative tasks:
>>   http://lists.racket-lang.org/listinfo/users
>>
>
>
>



Posted on the users mailing list.