lua-users home
lua-l archive

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



On Sat, Aug 10, 2013 at 1:18 AM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> function float_equal(lhs, rhs, epsilon)
>     return math.abs(lhs - rhs) < epsilon
> end

As mentioned before, if you have to do this, you need to use *relative* error,
not absolute error:
      return math.abs(lhs - rhs) < epsilon*rhs

Two zeros will never be equal to each other :-(