Skip to main content
gamedev.net
🔒 Locked

sqrt problem

Started by msikora 2 replies 950+ views
Original Post
msikora
msikora
i have a problem with calculating sqrt function after InitD3D (directX 9) call.

here's a part of my code - the begining of WinMain:

...

double broj=1.2345678901234567, rezul=0;
rezul=sqrt(broj*broj);

if(!d3d::InitD3D(hinstance,
Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}

broj=1.2345678901234567, rezul=0;
rezul= sqrt( broj * broj);

...

the problem is that before the InitD3D sqrt function returns:

rezul 1.2345678901234567 double

and after InitD3D sqrt returns:


rezul 1.2345678806304932 double

to me it seems that after InitD3D it is doing math in float not in double precision, although the type of the variable is double. float precision is not enough for me - i need double.

any explanations and solutions?

thanx,

marjan
SiCrane
SiCrane
Unless you use the D3DCREATE_FPU_PRESERVE flag when creating your device, it will change the floating point control word.
_swx_
_swx_
This might solve your problem:
http://stackoverflow.com/questions/559294/direct-3d-affecting-data-type-double
msikora
msikora
thanks friends, it solved my problem.

marjan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.