Re:Don't distract new programmers with OOP
by sid0 on Thursday March 17, 2011 @04:08AM
(#2335433)
Where exactly were you mixing integers and floats? In my experience it doesn't come up too often, and if it does (e.g. writing area = 2 * pi * r) you'd be better served changing the 2 to 2.0.
[ Parent
| on HN ]
I sometimes want to avoid using floats because of the inaccuracy that sometimes arise with their use. If I recall correctly, in Haskell division requires the numerator and denominator to be of the class fractional. So how I did integer division was something like this
round (fromIntegral x / fromIntegral y)
round is one of several functions that transform numbers to integers.