posit-2022.0.0.0: Posit Numbers
Safe HaskellSafe-Inferred
LanguageHaskell2010

Posit.Internal.PositC

Description

Library implementing standard 'Posit-3.2', and 'Posit-2022' numbers, as defined by the Posit Working Group 23 June 2018, and in 2022 respectively.

Synopsis

Documentation

class FixedWidthInteger (IntN es) => 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

exponentSize | nBytes

Methods

encode Source #

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

decode Source #

Arguments

:: IntN es 
-> Maybe Rational

You have an integer with a finite integer log2 word size decode it and Maybe it is Rational

exponentSize Source #

Arguments

:: Natural

The exponent size, es is a Natural number

Exponent Size based on the Posit Exponent kind ES, Posit-2022 sets the default to 2.

nBytes Source #

Arguments

:: Natural

nBytes the number of bytes of the Posit Representation

Various other size definitions used in the Posit format with their default definitions

nBits Source #

Arguments

:: Natural

nBits the number of bits of the Posit Representation

signBitSize Source #

Arguments

:: Natural

signBitSize the size of the sign bit

uSeed Source #

Arguments

:: Natural

uSeed scaling factor for the regime of the Posit Representation

unReal Source #

Arguments

:: IntN es

unReal is something that is not Real, the integer value that is not a Real number

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

Instances details
PositC 'III_2022 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'III_3_2 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'II_2022 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'II_3_2 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'IV_2022 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'IV_3_2 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'I_2022 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'I_3_2 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'V_2022 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'V_3_2 Source # 
Instance details

Defined in Posit.Internal.PositC

PositC 'Z_2022 Source #

Standard 2022

Instance details

Defined in Posit.Internal.PositC

PositC 'Z_3_2 Source #

Standard 3.2

Instance details

Defined in Posit.Internal.PositC

data ES Source #

The Exponent Size ES kind, the constructor for the Type is a Roman Numeral.

type family IntN (es :: ES) where ... Source #

Type of the Finite Precision Representation, in our case Int8, Int16, Int32, Int64, Int128, Int256.

Equations

IntN Z_3_2 = Int8 
IntN I_3_2 = Int16 
IntN II_3_2 = Int32 
IntN III_3_2 = Int64 
IntN IV_3_2 = Int128_Storable 
IntN V_3_2 = Int256_Storable 
IntN Z_2022 = Int8 
IntN I_2022 = Int16 
IntN II_2022 = Int32 
IntN III_2022 = Int64 
IntN IV_2022 = Int128_Storable 
IntN V_2022 = Int256_Storable 

type FixedWidthInteger a = (Bits a, Bounded a, Enum a, Integral a, Eq a, Ord a, Num a, Read a, Show a, Storable a) Source #

The FixedWidthInteger is a Constraint Synonym that contains all of the constraints provided by the IntN Type Family. It is a super class for the Posit Class.

type family Max (es :: ES) where ... Source #

Type Max of Kind ES