lua-users home
lua-l archive

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


Ralph Hempel wrote:
Glenn McAllister wrote:
But interestingly, if I change the last assignment in the script from

  z = 2 ^ 3

to be

 z = y ^ 3

I now get the broken output:

 x =     8
 y =     2
 z =     4.0096609170284

Which may lead to thinking that y is not really 2

Agreed. I'm still stumped that it was happening when we *weren't* referring to y, however.


What happens when you ask for:

z = y ^ 2

z =	4

z = y ^ 4

z =     8.0193218340567


Adding the following to the end of the script:

 a = 2 ^ 3
 print ('a = ', a)

Gives me the following:

 x =     8
 y =     2
 z =     4.0096609170284
 a =     8

Looks like there might be some incompatibility in the numerical
representation on the PPC vs x86

You mention that the host is PPC-32 bit. What does its internal
float representation look like? Is it single or double precision?

From what I've been able to track down on the web, ppc has 32 64-bit registers for holding doubles. Single precision (32-bit) floating point values are contained in the register in double-precision format. So single-precision numbers have been rounded in some fashion. Apparently there are single precision and double precision float operations, and pushing double-precision values through single-precision operations can produce (as expected) garbage.


I'm assuming you're running some sort of POSIX kernel on the PPC
in an embedded box?

My bad. Linux kernel 2.6.27.4, custom built. We don't use a packaged distro, we build it all ourselves and have been for 9 years now. :)

(From other thread)
Ralph Hempel wrote:
Is your luaconf.h plain vanilla or have you changed any of the
definies for the math operators or number types

Plain vanilla.  We haven't changed anything.

--
Glenn McAllister     <glenn@somanetworks.com>      +1 416 348 1594
SOMA Networks, Inc.  http://www.somanetworks.com/  +1 416 977 1414