Copyright | (C) 2014 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | PatternSynonyms |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Numeric.Half.Internal
Contents
Description
Half-precision floating-point values. These arise commonly in GPU work and it is useful to be able to compute them and compute with them on the CPU as well.
Synopsis
- newtype Half = Half {
- getHalf :: CUShort
- isZero :: Half -> Bool
- fromHalf :: Half -> Float
- toHalf :: Float -> Half
- pattern POS_INF :: Half
- pattern NEG_INF :: Half
- pattern QNaN :: Half
- pattern SNaN :: Half
- pattern HALF_MIN :: Half
- pattern HALF_NRM_MIN :: Half
- pattern HALF_MAX :: Half
- pattern HALF_EPSILON :: Half
- pattern HALF_DIG :: (Eq a, Num a) => a
- pattern HALF_MIN_10_EXP :: (Eq a, Num a) => a
- pattern HALF_MAX_10_EXP :: (Eq a, Num a) => a
- pure_floatToHalf :: Float -> Half
- pure_halfToFloat :: Half -> Float
Documentation
Instances
Storable Half # | |
Defined in Numeric.Half.Internal Methods peekElemOff :: Ptr Half -> Int -> IO Half pokeElemOff :: Ptr Half -> Int -> Half -> IO () peekByteOff :: Ptr b -> Int -> IO Half pokeByteOff :: Ptr b -> Int -> Half -> IO () | |
Floating Half # | |
Defined in Numeric.Half.Internal | |
RealFloat Half # | |
Defined in Numeric.Half.Internal Methods floatRadix :: Half -> Integer floatDigits :: Half -> Int floatRange :: Half -> (Int, Int) decodeFloat :: Half -> (Integer, Int) encodeFloat :: Integer -> Int -> Half significand :: Half -> Half scaleFloat :: Int -> Half -> Half isInfinite :: Half -> Bool isDenormalized :: Half -> Bool isNegativeZero :: Half -> Bool | |
Generic Half # | |
Num Half # | |
Read Half # | |
Defined in Numeric.Half.Internal | |
Fractional Half # | |
Defined in Numeric.Half.Internal | |
Real Half # | |
Defined in Numeric.Half.Internal Methods toRational :: Half -> Rational | |
RealFrac Half # | |
Show Half # | |
Binary Half # | |
NFData Half # | |
Defined in Numeric.Half.Internal | |
Eq Half # | |
Ord Half # | |
Lift Half # | |
type Rep Half # | |
Defined in Numeric.Half.Internal type Rep Half = D1 ('MetaData "Half" "Numeric.Half.Internal" "half-0.3.1-3idE8ekn2f8FG9xQURPUxo" 'True) (C1 ('MetaCons "Half" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHalf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUShort))) |
Convert a Float
to a Half
with proper rounding, while preserving NaN and dealing appropriately with infinity
Patterns
These are available with GHC-7.8 and later.
pattern HALF_NRM_MIN :: Half #
Smallest positive normalized half
pattern HALF_EPSILON :: Half #
Smallest positive e for which half (1.0 + e) != half (1.0)
pattern HALF_DIG :: (Eq a, Num a) => a #
Number of base 10 digits that can be represented without change
pattern HALF_MIN_10_EXP :: (Eq a, Num a) => a #
pattern HALF_MAX_10_EXP :: (Eq a, Num a) => a #
Pure conversions
pure_floatToHalf :: Float -> Half #
Naive pure-Haskell implementation of toHalf
.
pure_halfToFloat :: Half -> Float #
Naive pure-Haskell implementation of fromHalf
.