2

I know that doubles are more precise than floats and that they should be used for financial stuff and other things that require precision, but why do we use floats? Why not just get rid of floats and use doubles for everything since they're more accurate?

Sorry, if this should've been asked somewhere else. I feel like only posts that contain code should go to stack overflow and I didn't know where else to ask this.

Adam Oates
  • 139
  • 3

1 Answers1

5

Doubles take twice more space. On some devices and for some applications this makes a difference. Think of 3D graphics: lots of numbers and no need for super-accurate results.

Also, financial transactions use integers (think dollars and cents) because they need not just accuracy, but exactness.

Marco
  • 337