0

Possible Duplicate:
Should I use double or float ?

When would I rather use double and when should I use float?

Community
  • 1
  • 1
lital maatuk
  • 5,345
  • 17
  • 53
  • 74

3 Answers3

2

The only time you need to use float is when you are storing large arrays of numbers. There is generally little difference in speed between the two and natively most things are double anyway.

Gabe
  • 79,868
  • 10
  • 131
  • 226
2

It's all about precision.

If you need to store very precise numbers then use a double.

If you need to store less precise numbers and are worried about the size of memory you're using then use a float.

Nick
  • 22,728
  • 6
  • 44
  • 79
2

Use double when you require the range it supports. Refer to Range of floating-point numbers. You should also typically use the native type, so if you're doing graphics or GPU programming, probably better stick to floats.

But whatever you do, please, do not use either to represent currency or money.

yan
  • 19,660
  • 3
  • 33
  • 47