Numeric.Half

half-0.2.2.1: Half-precision floating-point

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

Numeric.Half

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

# Documentation

newtype Half

Constructors

Half |
Fields getHalf :: CUShort

Instances

Eq Half |
Floating Half |
Fractional Half |
Num Half |
Ord Half |
Read Half |
Real Half |
RealFloat Half |
RealFrac Half |
Show Half |
Storable Half |

isZero :: Half -> Bool

Is this `Half` equal to 0?

fromHalf :: Half -> Float

Convert a `Half` to a `Float` while preserving NaN

toHalf :: Float -> Half

Convert a `Float` to a `Half` with proper rounding, while preserving NaN and dealing appropriately with infinity

pattern POS_INF :: Half

Positive infinity

pattern NEG_INF :: Half

Negative infinity

pattern QNaN :: Half

Quiet NaN

pattern SNaN :: Half

Signalling NaN

pattern HALF_MIN :: Half

Smallest positive half

pattern HALF_NRM_MIN :: Half

Smallest positive normalized half

pattern HALF_MAX :: Half

Largest positive 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