Re: [Haskell-cafe] Typing problems with basic arithmetic - help!

Thanks for this: All I have to do now is fix the fact that my maths is stupidly screwed! On Fri, Sep 23, 2005 at 02:23:10PM -0400, J. Garrett Morris wrote:
Haskell doesn't do automatic numeric conversion for you - you need to use fromIntegral to go from an integral type (like 2) to a floating point type (as you'd need for division) and you can use round or trunc to go the other direction. There's similarly a fromRational function to convert from rational numbers to just about anything else you'd need. A couple of applications of those functions - probably mainly around your divisions - should fix things up.
/g

On Fri, 23 Sep 2005, Marcin Tustin wrote:
Thanks for this: All I have to do now is fix the fact that my maths is stupidly screwed!
'div' is the integer division and rounds down. You should either use Rational (or Double) everywhere or use % which builds a ratio from two integers.
participants (2)
-
Henning Thielemann
-
Marcin Tustin