fixed-0.3: Signed 15.16 precision fixed point arithmetic

Copyright | (C) 2014-15 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell98

Numeric.Fixed

Description

Fixed precision arithmetic. This format is the same format used by OpenGL ES 1's `GLfixed` data type:

One sign bit, 15 bits to the left of the decimal place and 16 bits to the right packed into a 32-bit integer.

Synopsis

- newtype Fixed = Fixed {
  - getFixed :: CInt
  }
- fromFixed :: Fixed -> Double
- toFixed :: Double -> Fixed

# Documentation

newtype Fixed Source #

A signed 2s complement 15.16 scale fixed precision number

Constructors

Fixed |

Fields

- getFixed :: CInt

#### Instances

Instances details

Bounded Fixed Source # |
Instance details Defined in Numeric.Fixed Methods minBound :: Fixed maxBound :: Fixed
Enum Fixed Source # |
Instance details Defined in Numeric.Fixed Methods succ :: Fixed -> Fixed pred :: Fixed -> Fixed toEnum :: Int -> Fixed fromEnum :: Fixed -> Int enumFrom :: Fixed -> [Fixed] enumFromThen :: Fixed -> Fixed -> [Fixed] enumFromTo :: Fixed -> Fixed -> [Fixed] enumFromThenTo :: Fixed -> Fixed -> Fixed -> [Fixed]
Eq Fixed Source # |
Instance details Defined in Numeric.Fixed Methods (==) :: Fixed -> Fixed -> Bool (/=) :: Fixed -> Fixed -> Bool
Floating Fixed Source # |

Instance details

Defined in Numeric.Fixed

Methods

pi :: Fixed

exp :: Fixed -> Fixed

log :: Fixed -> Fixed

sqrt :: Fixed -> Fixed

(**) :: Fixed -> Fixed -> Fixed

logBase :: Fixed -> Fixed -> Fixed

sin :: Fixed -> Fixed

cos :: Fixed -> Fixed

tan :: Fixed -> Fixed

asin :: Fixed -> Fixed

acos :: Fixed -> Fixed

atan :: Fixed -> Fixed

sinh :: Fixed -> Fixed

cosh :: Fixed -> Fixed

tanh :: Fixed -> Fixed

asinh :: Fixed -> Fixed

acosh :: Fixed -> Fixed

atanh :: Fixed -> Fixed

log1p :: Fixed -> Fixed

expm1 :: Fixed -> Fixed

log1pexp :: Fixed -> Fixed

log1mexp :: Fixed -> Fixed

Fractional Fixed Source # |
Instance details Defined in Numeric.Fixed Methods (/) :: Fixed -> Fixed -> Fixed recip :: Fixed -> Fixed fromRational :: Rational -> Fixed
Num Fixed Source # |
Instance details Defined in Numeric.Fixed Methods (+) :: Fixed -> Fixed -> Fixed (-) :: Fixed -> Fixed -> Fixed (*) :: Fixed -> Fixed -> Fixed negate :: Fixed -> Fixed abs :: Fixed -> Fixed signum :: Fixed -> Fixed fromInteger :: Integer -> Fixed
Ord Fixed Source # |
Instance details Defined in Numeric.Fixed Methods compare :: Fixed -> Fixed -> Ordering (<) :: Fixed -> Fixed -> Bool (<=) :: Fixed -> Fixed -> Bool (>) :: Fixed -> Fixed -> Bool (>=) :: Fixed -> Fixed -> Bool max :: Fixed -> Fixed -> Fixed min :: Fixed -> Fixed -> Fixed
Real Fixed Source # |
Instance details Defined in Numeric.Fixed Methods toRational :: Fixed -> Rational
RealFloat Fixed Source # |

Instance details

Defined in Numeric.Fixed

Methods

floatRadix :: Fixed -> Integer

floatDigits :: Fixed -> Int

floatRange :: Fixed -> (Int, Int)

decodeFloat :: Fixed -> (Integer, Int)

encodeFloat :: Integer -> Int -> Fixed

exponent :: Fixed -> Int

significand :: Fixed -> Fixed

scaleFloat :: Int -> Fixed -> Fixed

isNaN :: Fixed -> Bool

isInfinite :: Fixed -> Bool

isDenormalized :: Fixed -> Bool

isNegativeZero :: Fixed -> Bool

isIEEE :: Fixed -> Bool

atan2 :: Fixed -> Fixed -> Fixed

RealFrac Fixed Source # |
Instance details Defined in Numeric.Fixed Methods properFraction :: Integral b => Fixed -> (b, Fixed) truncate :: Integral b => Fixed -> b round :: Integral b => Fixed -> b ceiling :: Integral b => Fixed -> b floor :: Integral b => Fixed -> b
Show Fixed Source # |
Instance details Defined in Numeric.Fixed Methods showsPrec :: Int -> Fixed -> ShowS show :: Fixed -> String showList :: [Fixed] -> ShowS
Storable Fixed Source # |
Instance details Defined in Numeric.Fixed Methods sizeOf :: Fixed -> Int alignment :: Fixed -> Int peekElemOff :: Ptr Fixed -> Int -> IO Fixed pokeElemOff :: Ptr Fixed -> Int -> Fixed -> IO () peekByteOff :: Ptr b -> Int -> IO Fixed pokeByteOff :: Ptr b -> Int -> Fixed -> IO () peek :: Ptr Fixed -> IO Fixed poke :: Ptr Fixed -> Fixed -> IO ()

fromFixed :: Fixed -> Double Source #

Convert from a `Fixed` precision value to a `Double`

toFixed :: Double -> Fixed Source #

Convert from a `Double` to a `Fixed` precision value