[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua evolution and C99
- From: Leo Razoumov <slonik.az@...>
- Date: Tue, 9 Aug 2011 06:50:29 -0400
On Tue, Aug 9, 2011 at 01:33, David Kastrup <firstname.lastname@example.org> wrote:
> Leo Razoumov <email@example.com> 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
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).
To bring this discussion back to Lua I think that sensible approach
would be to keep lua_Number double while providing complex numbers by
means of userdata which is what is normally done anyway.