planet-mitchell-0.1.0: Planet Mitchell

Num.RealFrac

Contents

Synopsis

RealFrac

class (Real a, Fractional a) => RealFrac a where #

Extracting components of fractions.

Minimal complete definition

properFraction

Methods

properFraction :: Integral b => a -> (b, a) #

The function properFraction takes a real fractional number x and returns a pair (n,f) such that x = n+f, and:

• n is an integral number with the same sign as x; and
• f is a fraction with the same type and sign as x, and with absolute value less than 1.

The default definitions of the ceiling, floor, truncate and round functions are in terms of properFraction.

truncate :: Integral b => a -> b #

truncate x returns the integer nearest x between zero and x

round :: Integral b => a -> b #

round x returns the nearest integer to x; the even integer if x is equidistant between two integers

ceiling :: Integral b => a -> b #

ceiling x returns the least integer not less than x

floor :: Integral b => a -> b #

floor x returns the greatest integer not greater than x

Instances
 WARNING: the methods of the RealFrac instance need to compute the magnitude 10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program! Instance detailsDefined in Data.Scientific MethodsproperFraction :: Integral b => Scientific -> (b, Scientific) #truncate :: Integral b => Scientific -> b #round :: Integral b => Scientific -> b #ceiling :: Integral b => Scientific -> b #floor :: Integral b => Scientific -> b # Instance detailsDefined in Foreign.C.Types MethodsproperFraction :: Integral b => CFloat -> (b, CFloat) #truncate :: Integral b => CFloat -> b #round :: Integral b => CFloat -> b #ceiling :: Integral b => CFloat -> b #floor :: Integral b => CFloat -> b # Instance detailsDefined in Foreign.C.Types MethodsproperFraction :: Integral b => CDouble -> (b, CDouble) #truncate :: Integral b => CDouble -> b #round :: Integral b => CDouble -> b #ceiling :: Integral b => CDouble -> b #floor :: Integral b => CDouble -> b # Instance detailsDefined in Numeric.Half MethodsproperFraction :: Integral b => Half -> (b, Half) #truncate :: Integral b => Half -> b #round :: Integral b => Half -> b #ceiling :: Integral b => Half -> b #floor :: Integral b => Half -> b # Instance detailsDefined in Data.Time.Clock.Internal.NominalDiffTime Methodstruncate :: Integral b => NominalDiffTime -> b #round :: Integral b => NominalDiffTime -> b #ceiling :: Integral b => NominalDiffTime -> b #floor :: Integral b => NominalDiffTime -> b # Instance detailsDefined in Data.Time.Clock.Internal.DiffTime MethodsproperFraction :: Integral b => DiffTime -> (b, DiffTime) #truncate :: Integral b => DiffTime -> b #round :: Integral b => DiffTime -> b #ceiling :: Integral b => DiffTime -> b #floor :: Integral b => DiffTime -> b # Instance detailsDefined in Data.Constraint Methodsins :: () :- RealFrac Double # () :=> (RealFrac Float) Instance detailsDefined in Data.Constraint Methodsins :: () :- RealFrac Float # Integral a => RealFrac (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real MethodsproperFraction :: Integral b => Ratio a -> (b, Ratio a) #truncate :: Integral b => Ratio a -> b #round :: Integral b => Ratio a -> b #ceiling :: Integral b => Ratio a -> b #floor :: Integral b => Ratio a -> b # HasResolution a => RealFrac (Fixed a) Since: base-2.1 Instance detailsDefined in Data.Fixed MethodsproperFraction :: Integral b => Fixed a -> (b, Fixed a) #truncate :: Integral b => Fixed a -> b #round :: Integral b => Fixed a -> b #ceiling :: Integral b => Fixed a -> b #floor :: Integral b => Fixed a -> b # RealFrac a => RealFrac (Identity a) Instance detailsDefined in Data.Functor.Identity MethodsproperFraction :: Integral b => Identity a -> (b, Identity a) #truncate :: Integral b => Identity a -> b #round :: Integral b => Identity a -> b #ceiling :: Integral b => Identity a -> b #floor :: Integral b => Identity a -> b # (Precise a, RealFloat a) => RealFrac (Log a) Instance detailsDefined in Numeric.Log MethodsproperFraction :: Integral b => Log a -> (b, Log a) #truncate :: Integral b => Log a -> b #round :: Integral b => Log a -> b #ceiling :: Integral b => Log a -> b #floor :: Integral b => Log a -> b # (Integral a) :=> (RealFrac (Ratio a)) Instance detailsDefined in Data.Constraint Methods (RealFrac a) :=> (RealFrac (Identity a)) Instance detailsDefined in Data.Constraint Methods (RealFrac a) :=> (RealFrac (Const a b)) Instance detailsDefined in Data.Constraint Methodsins :: RealFrac a :- RealFrac (Const a b) # Class (Real a, Fractional a) (RealFrac a) Instance detailsDefined in Data.Constraint Methodscls :: RealFrac a :- (Real a, Fractional a) # Class (RealFrac a, Floating a) (RealFloat a) Instance detailsDefined in Data.Constraint Methodscls :: RealFloat a :- (RealFrac a, Floating a) # RealFrac a => RealFrac (Const a b) Instance detailsDefined in Data.Functor.Const MethodsproperFraction :: Integral b0 => Const a b -> (b0, Const a b) #truncate :: Integral b0 => Const a b -> b0 #round :: Integral b0 => Const a b -> b0 #ceiling :: Integral b0 => Const a b -> b0 #floor :: Integral b0 => Const a b -> b0 # RealFrac a => RealFrac (Tagged s a) Instance detailsDefined in Data.Tagged MethodsproperFraction :: Integral b => Tagged s a -> (b, Tagged s a) #truncate :: Integral b => Tagged s a -> b #round :: Integral b => Tagged s a -> b #ceiling :: Integral b => Tagged s a -> b #floor :: Integral b => Tagged s a -> b #

Reads an unsigned RealFrac value, expressed in decimal scientific notation.