lua-users home
lua-l archive

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

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
Lua 5.1.4  Copyright (C) 1994-2008, 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.

┌─── ───── ─────
│ "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

Attachment: signature.asc
Description: OpenPGP digital signature