fixed-0.2.1.1: 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

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

Instance details

Defined in Numeric.Fixed

Methods

pi :: Fixed Source #

exp :: Fixed -> Fixed Source #

log :: Fixed -> Fixed Source #

sqrt :: Fixed -> Fixed Source #

(**) :: Fixed -> Fixed -> Fixed Source #

logBase :: Fixed -> Fixed -> Fixed Source #

sin :: Fixed -> Fixed Source #

cos :: Fixed -> Fixed Source #

tan :: Fixed -> Fixed Source #

asin :: Fixed -> Fixed Source #

acos :: Fixed -> Fixed Source #

atan :: Fixed -> Fixed Source #

sinh :: Fixed -> Fixed Source #

cosh :: Fixed -> Fixed Source #

tanh :: Fixed -> Fixed Source #

asinh :: Fixed -> Fixed Source #

acosh :: Fixed -> Fixed Source #

atanh :: Fixed -> Fixed Source #

log1p :: Fixed -> Fixed Source #

expm1 :: Fixed -> Fixed Source #

log1pexp :: Fixed -> Fixed Source #

log1mexp :: Fixed -> Fixed Source #

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

Instance details

Defined in Numeric.Fixed

Methods

floatRadix :: Fixed -> Integer Source #

floatDigits :: Fixed -> Int Source #

floatRange :: Fixed -> (Int, Int) Source #

decodeFloat :: Fixed -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Fixed Source #

exponent :: Fixed -> Int Source #

significand :: Fixed -> Fixed Source #

scaleFloat :: Int -> Fixed -> Fixed Source #

isNaN :: Fixed -> Bool Source #

isInfinite :: Fixed -> Bool Source #

isDenormalized :: Fixed -> Bool Source #

isNegativeZero :: Fixed -> Bool Source #

isIEEE :: Fixed -> Bool Source #

atan2 :: Fixed -> Fixed -> Fixed Source #

RealFrac Fixed Source # |
Instance details Defined in Numeric.Fixed Methods properFraction :: Integral b => Fixed -> (b, Fixed) Source # truncate :: Integral b => Fixed -> b Source # round :: Integral b => Fixed -> b Source # ceiling :: Integral b => Fixed -> b Source # floor :: Integral b => Fixed -> b Source #
Show Fixed Source # |
Instance details Defined in Numeric.Fixed Methods showsPrec :: Int -> Fixed -> ShowS Source # show :: Fixed -> String Source # showList :: [Fixed] -> ShowS Source #
Storable Fixed Source # |

Instance details

Defined in Numeric.Fixed

Methods

sizeOf :: Fixed -> Int Source #

alignment :: Fixed -> Int Source #

peekElemOff :: Ptr Fixed -> Int -> IO Fixed Source #

pokeElemOff :: Ptr Fixed -> Int -> Fixed -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Fixed Source #

pokeByteOff :: Ptr b -> Int -> Fixed -> IO () Source #

peek :: Ptr Fixed -> IO Fixed Source #

poke :: Ptr Fixed -> Fixed -> IO () Source #

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