lua-users home
lua-l archive

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


You are right.

print( ( -1.0702700000075937e-05 ) ^( 1 / 2.19921875 ) ) retults too a -nan. If I understand this right the result is a -nan because it would be a complex number.

-- Jasper


Op Sun, 27 Oct 2019 19:15:35 +0100 schreef Gabriel Bertilson <arboreous.philologist@gmail.com>:

^ is higher in operator precedence than unary -. So for instance -2^2
is equivalent to -(2^2), whereas b^2, where b is equal to -2, is
equivalent to (-2)^2. They evaluate to -4.0 and 4.0 respectively. Your
examples are similar; they should evaluate to different values.

— Gabriel

On Sun, Oct 27, 2019 at 12:44 PM Jasper Klein <jasper@klein.re> wrote:

Hi,

There is an issue with a calulation I did with Lua 5.3.5 and the latest
5.4 beta.

The result of the two lines below is a '-nan'
> b = -1.0702700000075937e-05
> print( b ^( 1 / 2.19921875 ) )

While this line prints the number '-0.005493842385624'
> print( -1.0702700000075937e-05 ^ ( 1 / 2.19921875 ) )

-- Jasper