HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduledimensional-1.5Haskell2010

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.

  • 22 values
  • Packagedimensional-1.5
  • Exports23
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFloat.hs

Lifted Predicates from RealFloat

4 declarations
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

2 declarations
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

0 declarations

Values

valueminNormal :: IEEE a => Quantity d a
#

The smallest representable positive quantity whose representation is normalized.

Arithmetic

valuepredIEEE :: IEEE a => Quantity d a -> Quantity d a
#

Return the next smallest representable floating-point quantity (Infinity and NaN are unchanged).

valuesuccIEEE :: IEEE a => Quantity d a -> Quantity d a
#

Return the next largest representable floating-point quantity (Infinity and NaN are unchanged).

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