[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] Converting from Int to Double
From: Jorge Adriano Aires <jadrian () mat ! uc ! pt>
Date: 2005-01-26 21:09:17
Message-ID: 200501262109.17193.jadrian () mat ! uc ! pt
[Download RAW message or body]
> >> How can I convert an Int into a Double?
> >
> > You don't convert to, you convert from :-)
> > The function 'fromIntegral' is probably what you want.
>
> And what function can I use to convert from Double to Int (the inverse of
> fromIntegral) ?
Use the functions in the RealFrac class.
http://www.haskell.org/onlinereport/standard-prelude.html#$tRealFrac
class (Real a, Fractional a) => RealFrac a where
properFraction :: (Integral b) => a -> (b,a)
truncate, round :: (Integral b) => a -> b
ceiling, floor :: (Integral b) => a -> b
J.A.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic