HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduledimensional-1.6.2Haskell2010

Numeric.Units.Dimensional.Float

Defines convenience functions for inspecting and manipulating quantities with RealFloat floating-point representations.

The dimensionally-typed versions of functions from Patrick Perry's ieee754 package copy that packages API as closely as possible, by permission. In turn they are based on the tango math library for the D language.

Contents
  1. Lifted Predicates from RealFloat
  2. Convenience Functions
  3. Lifted Functions from Numeric.IEEE
  4. Values
  5. Arithmetic
  6. NaN with Payload
  7. Comparisons
Synopsis
  • Packagedimensional-1.6.2
  • Exports23
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFloat.hs

Lifted Predicates from RealFloat

valueisInfinite :: RealFloat a => Quantity d a -> Bool

True if the representation of the argument is an IEEE infinity or negative infinity.

Example1 expression
isInfinite (_1 / _0)True
Example1 expression
isInfinite (42 *~ micro farad)False
valueisNaN :: RealFloat a => Quantity d a -> Bool

True if the representation of the argument is an IEEE "not-a-number" (NaN) value.

Example1 expression
isNaN _3False
Example1 expression
isNaN (_1 / _0)False
Example1 expression
isNaN (asin _4)True
valueisNegativeZero :: RealFloat a => Quantity d a -> Bool

True if the representation of the argument is an IEEE negative zero.

Example1 expression
isNegativeZero _0False
Example1 expression
isNegativeZero $ (-1e-200 *~ one) * (1e-200 *~ one)True

Convenience Functions

valueisFiniteNumber :: RealFloat a => Quantity d a -> Bool

True if the representation of the argument is a number and is not infinite.

Example1 expression
isFiniteNumber (_1 / _0)False
Example1 expression
isFiniteNumber (_0 / _0)False
Example1 expression
isFiniteNumber (_3 / _2)True
valuescaleFloat :: RealFloat a => Int -> Quantity d a -> Quantity d a

Multiplies a floating-point quantity by an integer power of the radix of the representation type.

Use floatRadix to determine the radix.

Example2 expressions
let x = 3 *~ meterscaleFloat 3 x24.0 m

Lifted Functions from Numeric.IEEE

Values

Arithmetic

valuebisectIEEE :: IEEE a => Quantity d a -> Quantity d a -> Quantity d a

Given two floating-point quantities with the same sign, return the quantity whose representation is halfway between their representations on the IEEE number line. If the signs of the values differ or either is NaN, the value is undefined.

NaN with Payload

valuenanWithPayload :: IEEE a => Word64 -> Quantity d a

Quiet NaN quantity with a positive integer payload. Payload must be less than maxNaNPayload of the representation type.

Beware that while some platforms allow using 0 as a payload, this behavior is not portable.

Comparisons