Why do you need float/double?

Posted by acidzombie24 on Programmers See other posts from Programmers or by acidzombie24
Published on 2011-06-27T20:15:12Z Indexed on 2011/06/28 0:29 UTC
Read the original article Hit count: 508

Filed under:
|
|
|

I was watching http://www.joelonsoftware.com/items/2011/06/27.html and laughed at Jon Skeet joke about 0.3 not being 0.3. I personally never had problems with floats/decimals/doubles but then I remember I learned 6502 very early and never needed floats in most of my programs. The only time I used it was for graphics and math where inaccurate numbers were ok and the output was for the screen and not to be stored (in a db, file) or dependent on.

My question is, where are places were you typically use floats/decimals/double? So I know to watch out for these gotchas. With money I use longs and store values by the cent, for speed of an object in a game I add ints and divide (or bitshift) the value to know if I need to move a pixel or not. (I made object move in the 6502 days, we had no divide nor floats but had shifts).

So I was mostly curious.

© Programmers or respective owner

Related posts about decimal

Related posts about double