rounded-0.1.0.1: Correctly-rounded arbitrary-precision floating-point arithmetic

Copyright(C) 2012-2014 Edward Kmett Daniel Peebles
(C) 2013-2018 Claude Heiland-Allen
LicenseBSD3
MaintainerClaude Heiland-Allen <claude@mathr.co.uk>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Numeric.Rounded.Simple

Contents

Description

This module provides an interface without advanced type system features, that may be more convenient if the precision is changed often.

Synopsis

Floating point numbers with a specified rounding mode and precision

data Rounded #

A properly rounded floating-point number with a given rounding mode and precision.

Instances
Eq Rounded # 
Instance details

Defined in Numeric.Rounded.Simple

Methods

(==) :: Rounded -> Rounded -> Bool #

(/=) :: Rounded -> Rounded -> Bool #

Ord Rounded # 
Instance details

Defined in Numeric.Rounded.Simple

reifyRounded :: Rounded -> (forall p. Precision p => Rounded r p -> a) -> a #

Precision

type Precision = Int #

Rounding

data RoundingMode #

Constructors

TowardNearestWithTiesAwayFromZero

currently unsupported placeholder

TowardNearest

roundTiesToEven in IEEE 754-2008

TowardZero

roundTowardZero in IEEE 754-2008

TowardInf

roundTowardPositive in IEEE 754-2008

TowardNegInf

roundTowardNegative in IEEE 754-2008

AwayFromZero

round away from zero

Faithfully

currently unsupported placeholder

Instances
Bounded RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Enum RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Eq RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Data RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RoundingMode -> c RoundingMode #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RoundingMode #

toConstr :: RoundingMode -> Constr #

dataTypeOf :: RoundingMode -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RoundingMode) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RoundingMode) #

gmapT :: (forall b. Data b => b -> b) -> RoundingMode -> RoundingMode #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RoundingMode -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RoundingMode -> r #

gmapQ :: (forall d. Data d => d -> u) -> RoundingMode -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RoundingMode -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RoundingMode -> m RoundingMode #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RoundingMode -> m RoundingMode #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RoundingMode -> m RoundingMode #

Ord RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Read RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

Show RoundingMode # 
Instance details

Defined in Numeric.Rounded.Rounding

SingI TowardNearestWithTiesAwayFromZero # 
Instance details

Defined in Numeric.Rounded.Rounding

SingI TowardNearest # 
Instance details

Defined in Numeric.Rounded.Rounding

SingI TowardZero # 
Instance details

Defined in Numeric.Rounded.Rounding

Methods

sing :: Sing TowardZero #

SingI TowardInf # 
Instance details

Defined in Numeric.Rounded.Rounding

Methods

sing :: Sing TowardInf #

SingI TowardNegInf # 
Instance details

Defined in Numeric.Rounded.Rounding

SingI AwayFromZero # 
Instance details

Defined in Numeric.Rounded.Rounding

SingI Faithfully # 
Instance details

Defined in Numeric.Rounded.Rounding

Methods

sing :: Sing Faithfully #

newtype Sing (m :: RoundingMode) # 
Instance details

Defined in Numeric.Rounded.Rounding

Useful Constants

Ord

Num

Fractional

Real

RealFrac

Floating

RealFloat

Show

Read

Foreign Function Interface

withInRounded :: Rounded -> (Ptr MPFR -> IO a) -> IO a #

Use a value as a constant mpfr_t (attempts to modify it may explode, changing the precision will explode).

withInOutRounded :: Rounded -> (Ptr MPFR -> IO a) -> IO (Rounded, a) #

Allocates and initializes a new mpfr_t to the value. After the action it is peeked and returned.

withInOutRounded_ :: Rounded -> (Ptr MPFR -> IO a) -> IO Rounded #

Allocates and initializes a new mpfr_t to the value. After the action it is peeked and returned. The result of the action is ignored.

withOutRounded :: Precision -> (Ptr MPFR -> IO a) -> IO (Rounded, a) #

Allocates and initializes a new mpfr_t, after the action it is peeked and returned.

withOutRounded_ :: Precision -> (Ptr MPFR -> IO a) -> IO Rounded #

Allocates and initializes a new mpfr_t, after the action it is peeked and returned. The result of the action is ignored.

peekRounded :: Ptr MPFR -> IO Rounded #

Peek an mpfr_t at its actual precision.