lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9/20/2010 4:45 AM, HyperHacker wrote:
On Sun, Sep 19, 2010 at 13:49, David Kastrup wrote:
[snipped all]
Negative zero is an artifact of how some systems implement some
floating-point operations. Unlike integers, floating-point values have
a sign bit. Some systems won't clear the sign when the result is zero,
hence -0. It should function identically to zero in all operations,
including comparing to zero. I can't confirm that it does, as I can't
seem to generate one.

Note that a number displayed as -0.0000 could also be a  very small
negative number rounded to fit the display, e.g.:
=('%f'):format(-0.00000001)
-0.000000
%f rounds to six places by default. This is the proper meaning of
negative zero - a negative value that rounded to zero.

It'd probably save you a lot of headache in the future to read up on
how floating-point works, as it has a lot of potential pitfalls.

This is the kind of unnecessary noise that I am talking about. Mike, the OP, knows what he's doing. He has code and data samples to provide to the list.

When someone displays good problem-solving behaviour, engaging in hand-waving generalities is generally a waste of time. There is already enough information to enable us to study the issue in some detail.

The equations in the code would rule out small negative numbers, no need to dawdle on that. The "Negative zero is an artifact" is also a waste of time -- you can't seem to generate one, but you speculate about what perhaps can generally happen. Such information is not really of much use to us. If we want to build reliable software, we must do better than that.

When we have a specific problem and data is available, let's try to focus on the problem at hand. Discussing information pertinent and specific to the problem at hand can help eliminate potential diagnostic candidates.

Anyone can engage in hand-waving, but let's not go overboard with it. Having a dozen hand-wavers here, I think, will not help solve anything at all. Just because we can wave our hands, doesn't mean we should do it all the time.

I am interested in a firm diagnosis of the issue. I hope Mike can enlighten the list when he is able to get to the bottom of this.

[Sent from my lawn. Ha ha... :-)]

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia