Solved: Strange behaviour of floating point calcs


11-02-2010 11:30:00

I've found the following strange problem in python-ogre 1.6.4:

I'have created an application which is based on (like most samples in the demo folder). After the line self.renderWindow = self.root.initialise(True,windowTitle)
in _configure the python changes the way it does floating point calculations. It looks as if the precision is reduced if properties are involved. The behaviour can be reproduced as follows:

Changes to

Add test class:

class Tester:
def __init__(self):

def show(self):
print "\nTest: ",repr(self.test*1.00000001),repr(self.test+0.9),"\n"

Changes to _configure:

self.renderWindow = self.root.initialise(True,windowTitle)

When I now run a demo (e.g. I find the following lines in the console output:

Test: 1000.00001 1000.9
Test: 1000.0 1000.9000244140625

The second calculation after intitialise() is clearly wrong.


03-03-2010 12:45:15

I've found a solution:
In ogre.cfg the floating point mode has to be changed from fastest to consistent:

Floating-point mode=Consistent