When should I use double instead of decimal?

后端 未结 12 1570
Happy的楠姐
Happy的楠姐 2020-11-22 10:51

I can name three advantages to using double (or float) instead of decimal:

  1. Uses less memory.
  2. Faster because flo
12条回答
  •  盖世英雄少女心
    2020-11-22 11:57

    Use a double or a float when you don't need precision, for example, in a platformer game I wrote, I used a float to store the player velocities. Obviously I don't need super precision here because I eventually round to an Int for drawing on the screen.

提交回复
热议问题