[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Floating point inaccuracies
- From: <jgiors@...>
- Date: Tue, 30 Nov 2010 12:31:01 -0700
> -------- Original Message --------
> Subject: RE: Floating point inaccuracies
> From: <jgiors@threeeyessoftware.com>
> Date: Tue, November 30, 2010 10:58 am
> To: jgiors@threeeyessoftware.com
> Cc: lua-l@lists.lua.org
>
>
> > -------- Original Message --------
> > Subject: Re: Floating point inaccuracies
> > From: <jgiors@threeeyessoftware.com>
> > Date: Tue, November 30, 2010 9:10 am
> > To: lua-l@lists.lua.org
> >
>
> <... snip ...>
>
> > I don't think changes to the number comparison operators can be
> > justified as a language default. However, since the __eq, __lt, and __le
> > metamethods can be overridden for numbers[*], it might be nice to create
> > a simple Lua library which implements epsilon comparison capability. I
> > don't know if there is anything like that currently available -- some
> > quick searches didn't turn up anything.
> >
> > John Giors
> > Independent Programmer
> > Three Eyes Software
> > jgiors@ThreeEyesSoftware.com
> > http://ThreeEyesSoftware.com
> >
> > [*] This is another strike against the proposal -- users can already
> > implement the proposed feature in Lua itself.
>
> Addendum: this cannot be done in pure Lua unless the debug library is
> used to set the metatable (which means it is a not so "nice" solution).
> The global setmetatable() only allows changing the metatable of tables,
> not numbers.
Addendum redux: I'm wrong about that. debug.setmetatable(1,t) does set
the metatable for numbers, but it does not have any effect on comparison
operations (which makes sense for optimization). Sorry about not
realizing that (only found out after I tried it). I bow my head in
appropriate shame.
John Giors
Independent Programmer
Three Eyes Software
jgiors@ThreeEyesSoftware.com
http://ThreeEyesSoftware.com