lua-users home
lua-l archive

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

Leo Razoumov <> writes:

> On Tue, Aug 9, 2011 at 01:33, David Kastrup <> wrote:
>> Leo Razoumov <> writes:
>>> Actually, making lua_Numbers complex is a bad idea. Complex numbers do
>>> not have a natural ordering relationship like real numbers do.
>>> With integers or real numbers you can assert that for any x,y
>>> assert((not (x<y) and not (y<x)) == (x==y))
>>> For complex numbers such an ordering operator does not exist.
>> Lexicographical ordering works just fine and fulfills that condition.
>> You could also just order the bit patterns.  Lots of other
>> possibilities.
> When ordering by bit-patterns you don't really care whether underlying
> entities are Complex Numbers or not. For example, such ordering would
> not preserve arithmetic operations. For example, for real numbers
> statements x>y and 3*x>3*y are equivalent. But I doubt that you can
> achieve the same equivalence for lexicographical order (for any
> positive constant in place of 3).

Lexicographic order is ordering first by real part, then (on equality)
by imaginary part.  Or vice versa.  It preserves that equivalence for
any positive real constant.

Not that this has _any_ bearing on why it should be a bad idea to make
lua_Numbers complex.

The only reason I can discern up to now from the discussion about why it
should be a bad idea to make lua_Numbers complex is that it will at
least triple the amount of non sequiturs posted to the list.

David Kastrup