• Subject: Re: exponent and modulus operator oddities on ppc
• From: Ralph Hempel <rhempel@...>
• Date: Mon, 02 Mar 2009 12:18:31 -0500

```Glenn McAllister wrote:

```
```What happens if you run the "morally equivalent" script from a file?
```
```
```
Sorry, I had changed around some of the variable for the interactive session to show that its any assignment of 2^3 that triggers the issue, and not just resetting y.
```
If I change the script to:

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

y = 10 % x
print('y = ', y)

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

I get the expected output:

x =     8
y =     2
z =     8
```
```
OK, so running from a script seems to work. So far so good.

```
Its z = 2^3, which should have the value of 8. So I'm using constants, not the variable.
```
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

What happens when you ask for:

z = y ^ 2
z = y ^ 4

```
```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?

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

Ralph

```