[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: compute cubic root with negative argument
- From: Christopher Kappe <kappe@...>
- Date: Fri, 15 Apr 2016 13:11:21 +0200
> The least one should do, is document the fact that exponentiation
> only works for a non-negative base argument.
> [...]
> The Lua documentation already says "Exponentiation uses the
> ISO C function pow". That is clean an unambiguous.
Just to clarify, that upper statement was not meant as an offense. It is
just that "similar cases" for other functions are documented more
explicitly (for Lua). But I agree that just referring to C here is okay
(also w.r.t. what others have answered).
If anyone is interested, I use the following now
if x >= 0 then
return x^(1/3)
else
return -( (-x)^(1/3) )
end
(I was mainly interested in a function symmetric to the origin and this
also works e.g. for exponent 1/2)