floating-bits-0.3.1.0: Bitwise accurate floating point conversion, and Unit of Lease Precision calculation.
Copyright (C) 2015 Anselm Jonas Scholl (C) 2023 Julia Longtin BSD3 Julia Longtin experimental GHC-specific Safe-Inferred Haskell2010

Data.Bits.Floating

Description

Functions for performing conversions between floating point values and Integral values, for retrieving the Unit of Least Precision of a floating point value, and for incrementing / decrementing a value by one ULP..

Synopsis

# Bitwise operations

class (Floating f, Integral w) => FloatingBits f w | f -> w where Source #

Methods

coerceToWord :: f -> w Source #

Coerce a floating point number to an integral number preserving the bitwise representation.

coerceToFloat :: w -> f Source #

Coerce a integral number to an floating point number preserving the bitwise representation.

Note: It is not always possible to do this. In particular, if we coerce the bit pattern of a NaN value, we might get a NaN value with a different bit pattern than we wanted, so it is possible that coerceToWord (coerceToFloat w) /= w.

nextUp :: f -> f Source #

Return the next floating point value in the direction of +INF. If the argument is NaN, NaN is returned. If the argument is +INF, +INF is returned. If the argument is 0.0, the minimum value greater than 0.0 is returned. If the argument is -INF, -INF is returned.

nextDown :: f -> f Source #

Return the next floating point value in the direction of -INF. If the argument is NaN, NaN is returned. If the argument is +INF, +INF is returned. If the argument is 0.0, the maximum value smaller than 0.0 is returned. If the argument is -INF, -INF is returned.

ulp :: f -> f Source #

Return the size of the Unit of Least Precision of the argument. If the argument is NaN, NaN is returned. If the argument is +INF or -INF, +INF is returned. If the argument is 0.0, the minimum value greater than 0.0 is returned.

If x is not NaN or one of the infinities, ulp x == ulp (-x) holds.

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods

# Printing

class ShowFloat f where Source #

Minimal complete definition

Methods

showsFloat :: f -> ShowS Source #

Like showFloat, but prepends the value to another string.

showFloat :: f -> String Source #

Convert a float to a string, but show additional information if it is a NaN value.

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods Source # Instance detailsDefined in Data.Bits.Floating Methods

# Utility functions

Cast a CFloat to a Float.

Cast a CDouble to a Double.