[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Detect negative zero (was Re: Infinity as index)
- From: "Liam Devine" <liamdevine@...>
- Date: Thu, 24 Apr 2014 19:42:43 +0100
On 24/04/14 19:22, Doug Currie wrote:
>>
>> On 24/04/14 17:15, Dirk Laurie wrote:
>>>
>>> The hardest test of all is to distinguish between 0 and -0.
>>> If you can improve on the following, please post.
>>>
>>> if x==0 and 1/x>0 then -- x is 0
>>> if x==0 and 1/x<0 then -- x is -0
>>
>
> You can get by without the and:
>
>> function is_minuszero (x) return 1/x == -1/0 end
>> function is_pluszero (x) return 1/x == 1/0 end
>
> e
>
The problem with both of these methods is you have just fired signals
for which the host could have set traps.
--
Liam
Attachment:
signature.asc
Description: OpenPGP digital signature