How can I avoid frequent int / float / double operations when developing an XNA application?

I am making a simple 2D game for Windows Phone 7 (Mango) using the XNA Framework.

I made the following comments:

  • Most drawing operations accept floats
  • SpriteBatch.Drawaccepts Rectanglethat uses ints
  • The class Mathtakes doubleas parameters, and also returns doubles

So my code is full of types with ints, floatand doubles. This is a hell of a lot of types.

Is there a way to get rid of them, or do I just not need to do this?

In addition, do these drives exist in the form of measurable performance losses?

+5
source share
2 answers

, , -. float int , float double . , float int, . (, Convert.ToInt32).   , . , :

  • float, double int multiplications == > ,
  • 4x 10x , , == > , .
  • 8 , ! == > , . 1/a,

, , . , , , , . AFAIK, Windows Phone doubles, Math, .

, , , XNA. , , , , , ( ).

+2

Rectangle, , Vector2 float:

http://msdn.microsoft.com/en-us/library/ff433988.aspx

, () - , ( # static, , ).

0

All Articles