Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualhpdvs2

Posted 10 January 2013 - 09:28 AM

I don't know the reason why, but from XNA documentation I've read, floats are faster than doubles.  but doubles have better accuracy.  Not as in number of digits, but as in valid data.  For instance, 1-1 in a double = 0.  but 1-1 as a float equals something more like 0.000000000000017.  For games, this gap was not as big of a deal as it would be in say scientific application physics engines or financial applications.

 

You could create your own Double classes if you really need to, but what I recommend, is to reproduce any math functions you need to use floats instead of doubles.

 

Since XNA relies on Floats at a lower level, you cannot get around using floats.  Even if you store your data as doubles and work with it as such, you still have to recast to floats prior to passing data into XNA's framework.  most common math functions are already duplicated in xna vectors/matrixes and the MathHelper class.  

 

If you are attaching a physics engine or something else that rellies on doubles, and it is not convenient, you will need to convert them with tools of your own to tie it into XNA.


#1hpdvs2

Posted 10 January 2013 - 09:27 AM

I don't know the reason why, but from XNA documentation I've read, floats are faster than doubles.  but doubles have better accuracy.  Not as in number of digits, but as in valid data.  For instance, 1-1 in a double = 0.  but 1-1 as a float equals something more like 0.000000000000017.  But for games, this gap was not as big of a deal as it would be in say scientific application physics engines or financial applications.

 

You could create your own Double classes if you really need to, but what I recommend, is to reproduce any math functions you need to use floats instead of doubles.

 

Since XNA relies on Floats at a lower level, you cannot get around using floats.  Even if you store your data as doubles and work with it as such, you still have to recast to floats prior to passing data into XNA's framework.  most common math functions are already duplicated in xna vectors/matrixes and the MathHelper class.  

 

If you are attaching a physics engine or something else that rellies on doubles, and it is not convenient, you will need to convert them with tools of your own to tie it into XNA.


PARTNERS