| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Posit.Internal.PositC
Contents
Description
Library implementing standard 'Posit-3.2' numbers, as defined by the Posit Working Group 23 June 2018.
Synopsis
- class PositC (es :: ES) where
- type IntN es = r | r -> es
- encode :: Maybe Rational -> IntN es
- decode :: IntN es -> Maybe Rational
- exponentSize :: Natural
- nBytes :: Natural
- nBits :: Natural
- signBitSize :: Natural
- uSeed :: Natural
- unReal :: IntN es
- mostPosVal :: IntN es
- leastPosVal :: IntN es
- leastNegVal :: IntN es
- mostNegVal :: IntN es
- maxPosRat :: Rational
- minPosRat :: Rational
- maxNegRat :: Rational
- minNegRat :: Rational
- log_uSeed :: (Integer, Rational) -> (Integer, Rational)
- getRegime :: Rational -> (Integer, Rational)
- posit2TupPosit :: Rational -> (Bool, Integer, Natural, Rational)
- buildIntRep :: Rational -> IntN es
- mkIntRep :: Integer -> Natural -> Rational -> IntN es
- formRegime :: Integer -> (IntN es, Integer)
- formExponent :: Natural -> Integer -> (IntN es, Integer)
- formFraction :: Rational -> Integer -> IntN es
- tupPosit2Posit :: (Bool, Integer, Natural, Rational) -> Maybe Rational
- regime2Integer :: IntN es -> (Integer, Int)
- findRegimeFormat :: IntN es -> Bool
- countRegimeBits :: Bool -> IntN es -> Int
- exponent2Nat :: Int -> IntN es -> Natural
- fraction2Posit :: Int -> IntN es -> Rational
- displayBin :: IntN es -> String
- decimalPrec :: Int
- data ES
Documentation
class PositC (es :: ES) where Source #
The Posit class is an approximation of ℝ, it is like a sampling on the Projective Real line ℙ(ℝ) with Maybe ℚ as the internal type.
The es is an index that controlls the log2 word size of the Posit's
fininte precision representation.
Minimal complete definition
encode, decode, exponentSize, unReal, mostPosVal, leastPosVal, leastNegVal, mostNegVal, buildIntRep, mkIntRep, formRegime, formExponent, formFraction, regime2Integer, findRegimeFormat, countRegimeBits, exponent2Nat, fraction2Posit, displayBin
Associated Types
type IntN es = r | r -> es Source #
Type of the Finite Precision Representation, in our case Int8, Int16, Int32, Int64, Int128, Int256. The es of kind ES will determine a result of r such that you can determine the es by the r
Methods
Arguments
| :: Maybe Rational | |
| -> IntN es | Maybe you have some Rational Number and you want to encode it as some integer with a finite integer log2 word size. |
Transform to/from the Infinite Precision Representation
Arguments
| :: IntN es | |
| -> Maybe Rational | You have an integer with a finite integer log2 word size decode it and Maybe it is Rational |
Arguments
| :: Natural | The exponent size, |
Exponent Size based on the Posit Exponent kind ES
Various other size definitions used in the Posit format with their default definitions
Arguments
| :: Natural |
|
Arguments
| :: IntN es |
|
Integer Representation of common bounds
mostPosVal :: IntN es Source #
leastPosVal :: IntN es Source #
leastNegVal :: IntN es Source #
mostNegVal :: IntN es Source #
maxPosRat :: Rational Source #
minPosRat :: Rational Source #
maxNegRat :: Rational Source #
minNegRat :: Rational Source #
log_uSeed :: (Integer, Rational) -> (Integer, Rational) Source #
getRegime :: Rational -> (Integer, Rational) Source #
posit2TupPosit :: Rational -> (Bool, Integer, Natural, Rational) Source #
buildIntRep :: Rational -> IntN es Source #
mkIntRep :: Integer -> Natural -> Rational -> IntN es Source #
formRegime :: Integer -> (IntN es, Integer) Source #
formExponent :: Natural -> Integer -> (IntN es, Integer) Source #
formFraction :: Rational -> Integer -> IntN es Source #
tupPosit2Posit :: (Bool, Integer, Natural, Rational) -> Maybe Rational Source #
regime2Integer :: IntN es -> (Integer, Int) Source #
findRegimeFormat :: IntN es -> Bool Source #
countRegimeBits :: Bool -> IntN es -> Int Source #
exponent2Nat :: Int -> IntN es -> Natural Source #
fraction2Posit :: Int -> IntN es -> Rational Source #
displayBin :: IntN es -> String Source #
decimalPrec :: Int Source #
Instances
The Exponent Size ES kind, the constructor for the Type is a Roman Numeral.
Orphan instances
| Storable Int128 Source # | |
| Storable Int256 Source # | |
| Storable Word128 Source # | |