how to resolve the case of c++ rounding off values, for example:
cos(6.2832) i get 1 instead of .99999
and
0.1 being only 0... what should i do
Printable View
how to resolve the case of c++ rounding off values, for example:
cos(6.2832) i get 1 instead of .99999
and
0.1 being only 0... what should i do
forgot to say thannk you!
It's only rounding on output, the variable contains a better value. Use the setprecision modifier from <iomanip> to select how many places after the comma are displayed.
On a side note, the Windows calculator claims that the result of cos(6.2832) is 0.99399308850723265435071042275478
thanks... but sometimes it still prints 0 if it is 0.000001. what could be the problem? Thank you for your reply.
Floating values only store a specific precision. I don't know the details, as they differ from compiler to compiler.
I think that varies from OS too OS too, at least we had that problem in Java at school, on some versions of NT/2000 it wrote 1, and on som e 1.000000000001
shocks... there are still inconsitencies... anyways.... thanks! at least im able to use <iomanip> even though it doesnt work as always. thanks
What about in DirectX
D3DVECTOR struct has a float x,y,z.
Seeing a vector represents character posistion I need to store movement variables as floats.
To eliminate warning of double to float, I have to make everything a float which is part of a units movement system.
Speed, TimeDelta, Velocity, Weight.....the list goes on.
So you are saying that float precision is different from machine to machine...
I need integral values, but I also need a definite precision on any CPU, how do I go about that?
Use a decimal number libray like Gnu MPL.
Floats in DX is pretty much the same. It is a DX standard. Even tho some HW vendors like to try to change that. So don't worry to much about vectors and matrix math in DX. Your GPU is handeling most of that...Quote:
Originally posted by Halsafar
What about in DirectX
D3DVECTOR struct has a float x,y,z.
Seeing a vector represents character posistion I need to store movement variables as floats.
To eliminate warning of double to float, I have to make everything a float which is part of a units movement system.
Speed, TimeDelta, Velocity, Weight.....the list goes on.
So you are saying that float precision is different from machine to machine...
I need integral values, but I also need a definite precision on any CPU, how do I go about that?