Module

Contract.Numeric.Rational

Arbitrary precision rational numbers (backed by BigInt).

Re-exports from Ctl.Internal.Types.Rational

#Rational

newtype Rational

Rational is a newtype over Ratio with a smart constructor reduce that allows to create a Rational safely. The constructor is not exposed. Rational also enforces the denominator to always be positive.

Instances

#RationalComponent

class RationalComponent (t :: Type)  where

Members

Instances

#recip

recip :: Rational -> Maybe Rational

Gives the reciprocal of a Rational. Returns Nothing if applied to zero since the reciprocal of zero is mathematically undefined.

#numerator

numerator :: Rational -> BigInt

Get the numerator of a Rational as BigInt.

#denominator

denominator :: Rational -> BigInt

Get the denominator of a Rational as BigInt.

#(%)

Operator alias for Ctl.Internal.Types.Rational.reduce (left-associative / precedence 7)

Modules