lua-users home
lua-l archive

Re: Must "attempt to get length of a number value" be an error?

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


> > [...] . Functions with
> > the annotation "integer/float" give integer results for integer
> > arguments and float results for float (or mixed) arguments.
> > [...]
> > math.abs(x)
> > Returns the absolute valud of x. (integer/float)
> 
> According to Lua manual, math.abs() must return the absolute value of its
> argument.
> Obviously, math.abs(math.mininteger) not equals to the absolute value.
> That's a bug.
> 
> "bug" means that behavior does not match documentation.
> Either behavior should be changed (to return correct result)
> or documentation should be changed (to claim math.abs as returning result
> modulo 2^64 instead of the correct result)
The manual has incompatible requirements. As it is clear in your
message, the manual requires that 'math.abs(math.mininteger)' returns
an integer. So, returning a float would fix a bug to create another
(behavior *still* does not match documentation). So, one solution is
to change the documentation; the other is to change the behavior *and*
the documentation.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /