plutus-tx-1.36.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.Sqrt

Synopsis

Documentation

data Sqrt Source #

Integer square-root representation, discarding imaginary integers.

Constructors

Imaginary

The number was negative, so we don't even attempt to compute it; just note that the result would be imaginary.

Exactly Integer

An exact integer result. The rsqrt of 4 is 'Exactly 2'.

Approximately Integer

The Integer component (i.e. the floor) of a non-integral result. The 'rsqrt 2' is 'Approximately 1'.

Instances

Instances details
Show Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

Eq Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

Methods

(==) :: Sqrt -> Sqrt -> Bool Source #

(/=) :: Sqrt -> Sqrt -> Bool Source #

FromData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

ToData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

UnsafeFromData Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

Lift DefaultUni Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

Methods

lift :: Sqrt -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) Source #

Typeable DefaultUni Sqrt Source # 
Instance details

Defined in PlutusTx.Sqrt

Methods

typeRep :: Proxy Sqrt -> RTCompile DefaultUni fun (Type TyName DefaultUni ()) Source #

rsqrt :: Rational -> Sqrt Source #

Calculates the sqrt of a ratio of integers. As x / 0 is undefined, calling this function with `d=0` results in an error.

isqrt :: Integer -> Sqrt Source #

Calculates the integer-component of the sqrt of n.