[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua minus null (-0)
- From: David Given <dg@...>
- Date: Wed, 08 Jun 2011 19:12:59 +0100
Everett L Williams II wrote:
> Last time I checked, sign or no sign, computers give a machine
> check when division by zero is attempted.
You may want to check again...
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> = 1 / 0
Floating point is fundamentally an *approximation* to real maths, and
not a very good one at that. There are lots of gotchas that people using
floating point have to bear in mind. Such as, for example, that 0.2
can't be represented in floating point.
So, yes, +0 and -0 are equivalent mathematically. But they're not
equivalent in the real world, and in certain (fairly rare but important)
situations it's important to be able to distinguish between them; inf
and -inf likewise. Which is why this sort of thing is exposed to the user.
┌─── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup
Description: OpenPGP digital signature