When to use a Float

前端 未结 7 1297
南笙
南笙 2021-02-03 18:40

Years ago I learned the hard way about precision problems with floats so I quit using them. However, I still run into code using floats and it make me cringe because I know som

7条回答
  •  天命终不由人
    2021-02-03 19:12

    All floating point calculations are inaccurature in a general case, floats just more so than doubles. If you want more information have a read of What Every Computer Scientist Should Know About Floating-Point Arithmetic

    As for when to use floats - they are often used when precision is less important than saving memory. For example simple particle simulations in video games.

提交回复
热议问题