[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua minus null (-0)
- From: David Kastrup <dak@...>
- Date: Mon, 06 Jun 2011 09:25:13 +0200
Dirk Laurie <firstname.lastname@example.org> writes:
> On Mon, Jun 06, 2011 at 01:47:09AM +0200, Martin Guy wrote:
>> It's bizarre to expose such an esoteric implementation detail so
>> baldly. Only an IEEE validation suite specialist would be worried
>> about seeing the "-"; for normal people, the "-" contains no
>> information and is just surprising/worrying.
> It's not whether you are a specialist or normal: it's whether the
> minus sign is relevant to your application or not. For example,
> you may be planning to calculate 1/x some time later. Knowing whether
> you're going to get -Inf or +Inf may well be useful even for normal
> Lua is about keeping types and keywords few and far between, and
> semantic rules short and simple. They don't come any shorter and
> simpler than "as in C".
Of course they can come shorter and simpler: "as is". As far as
semantic rules to rely on go, it means quite the same.
> Unfortunately, the implications of that rule may often be accessible
> to experts only.
You have to read the underlying code _and_ the C language standard _and_
the C implementation details to figure out the actual behavior for your
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> return math.max(0,-0)
> return math.min(0,-0)
> return math.max(-0,0)
> return math.min(-0,0)
> return math.abs(0)
> return math.abs(-0)
Please tell me how the C standard would prepare you for guessing the
outcome of the above without actually reading the underlying code.