[no bug]irrlicht affect multiplication calculation

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Kairu
Posts: 18
Joined: Mon Sep 08, 2008 11:03 am

[no bug]irrlicht affect multiplication calculation

Post by Kairu »

Code: Select all

       Dim xyz As Decimal = 123456789
        Dim xcv As Decimal = 1.23413323432

        Dim ccc As Double = xcv * xyz
        MsgBox("ccc = " & ccc)
which give ccc = 152362128

while should be 152362126.307332

i do realize it maybe problem in irrlicht wrapper , but can someone please check it if it happen in main irrlicht

thanks
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

windows calculator 152362126.30733179848
ubuntu calculator 152362126.307331798
-------------------------- as float----------------------------------------------

Code: Select all

	
f32 xyz = 123456789.0f;
f32 xcv = 1.23413323432;
f32 ccc = xcv * xyz;

Code: Select all

		xyz	1.2345679e+008	float
		xcv	1.2341332	float
		ccc	1.5236213e+008	float
diff: -3.69266820152
-------------------------- as mixed ----------------------------------------------

Code: Select all

	
f32 xyz = 123456789.0f;
f32 xcv = 1.23413323432;
f64 ccc = xcv * xyz;

Code: Select all

		xyz	1.2345679e+008	float
		xcv	1.2341332	float
		ccc	152362131.15056992	double
diff: -4.84323812152
-------------------------- as double ----------------------------------------------

Code: Select all

f64 xyz = 123456789.0f;
f64 xcv = 1.23413323432;
f64 ccc = xcv * xyz;

Code: Select all

		xyz	123456792.00000000	double
		xcv	1.2341332343200000	double
		ccc	152362130.00973150	double
diff: -3.70239970152

ok, looking at it, I would have expected float and mixed to mess up, but I'm little surprised the double result is so far off myself,.
BTW: I have no idea about visual basic...
^bump for the double result, that really makes me wonder
Last edited by zillion42 on Wed Feb 25, 2009 2:13 pm, edited 1 time in total.
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Post by drewbacca »

If you are using directX in irrlicht, by default, all your calculations will be done as floats even if you declare them as double.

To have your doubles act like doubles, you must use

createDeviceEx rather than createDevice

and set HighPrecisionFPU to true.

This is not a bug, but an easy mistake to make.[/url]
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

i used (always playing with it):

Code: Select all

	irr::SIrrlichtCreationParameters param;
	//param = driverQuery(param);
	
	param.WindowSize = core::dimension2di(1024,768);
	param.Fullscreen = false;
	param.AntiAlias = true;
	param.DriverType = video::EDT_DIRECT3D9;
	param.Vsync = true;
	param.HighPrecisionFPU = true;
	param.Doublebuffer = true;
	param.Bits = 32;
	
	//create pointers to device, scene manager, GUI env., sound engine, cursor--------------------------------
	device=createDeviceEx(param);
but setting high precision fpu to false crashed me a couple of times in other calculations, so I see there must be a connection. I will try GL and post results from the debugger aswell...

Edit: using 1.6 svn rev 2223
XP professional SP3 (build 2600)
Nvidia GeForce 8600M GT nv4_disp.dll 6.14.11.6763

EDIT2: using EDT_OPENGL 2.1.2

Code: Select all

f64 xyz = 123456789.0f;
f64 xcv = 1.23413323432;
f64 ccc = xcv * xyz;

Code: Select all

		xyz	123456792.00000000	double
		xcv	1.2341332343200000	double
		ccc	152362130.00973150	double
diff: -3.70239970152
same as EDT_DIRECT3D9

oops...
:oops: :oops: ^^^disregard stupidity^^^ on the other hand the debugger didnt show the misinterpretation caused by a single 'f' typo

Code: Select all

	
double xyz = 123456789.0;
double xcv = 1.23413323432;
double ccc = xcv * xyz;

Code: Select all

		xyz	123456789.00000000	double
		xcv	1.2341332343200000	double
		ccc	152362126.30733180	double
diff: -0,00000000152
Post Reply