Float package:hedgehog
Single-precision floating point numbers. It is desirable that this
type be at least equal in range and precision to the IEEE
single-precision type.
Non-negative floating num.
Generates a random floating-point number in the
[inclusive,exclusive) range.
This is a specialization of realFloat, offered for
convenience.
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws for
Floating. However,
(+),
(*) and
exp are
customarily expected to define an exponential field and have the
following properties:
- exp (a + b) = exp a * exp b
- exp (fromInteger 0) = fromInteger 1
a constant function, returning the number of digits of
floatRadix in the significand
a constant function, returning the radix of the representation (often
2)
a constant function, returning the lowest and highest values the
exponent may assume
Generates a random floating-point number in the
[inclusive,exclusive) range.
This generator works the same as integral, but for floating
point numbers.
Efficient, machine-independent access to the components of a
floating-point number.
The function
decodeFloat applied to a real floating-point
number returns the significand expressed as an
Integer and an
appropriately scaled exponent (an
Int). If
decodeFloat x yields
(m,n), then
x
is equal in value to
m*b^^n, where
b is the
floating-point radix, and furthermore, either
m and
n are both zero or else
b^(d-1) <= abs m <
b^d, where
d is the value of
floatDigits
x. In particular,
decodeFloat 0 = (0,0). If the
type contains a negative zero, also
decodeFloat (-0.0) =
(0,0).
The result of decodeFloat x is
unspecified if either of isNaN x or
isInfinite x is True.
encodeFloat performs the inverse of
decodeFloat in the
sense that for finite
x with the exception of
-0.0,
uncurry encodeFloat (decodeFloat x) = x.
encodeFloat m n is one of the two closest
representable floating-point numbers to
m*b^^n (or
±Infinity if overflow occurs); usually the closer, but if
m contains too many bits, the result may be rounded in the
wrong direction.
multiplies a floating-point number by an integer power of the radix
Construct a range which scales the second bound exponentially relative
to the size parameter.
This works the same as exponential, but for floating-point
values.
>>> bounds 0 $ exponentialFloat 0 10
(0.0,0.0)
>>> bounds 50 $ exponentialFloat 0 10
(0.0,2.357035250656098)
>>> bounds 99 $ exponentialFloat 0 10
(0.0,10.0)
Construct a range which scales the bounds exponentially relative to
the size parameter.
This works the same as exponentialFrom, but for
floating-point values.
>>> bounds 0 $ exponentialFloatFrom 0 (-10) 20
(0.0,0.0)
>>> bounds 50 $ exponentialFloatFrom 0 (-10) 20
(-2.357035250656098,3.6535836249197002)
>>> bounds 99 $ exponentialFloatFrom x (-10) 20
(-10.0,20.0)
Scale a floating-point number exponentially with the size parameter.
Shrink a floating-point number by edging towards a destination.
>>> take 7 (towardsFloat 0.0 100)
[0.0,50.0,75.0,87.5,93.75,96.875,98.4375]
>>> take 7 (towardsFloat 1.0 0.5)
[1.0,0.75,0.625,0.5625,0.53125,0.515625,0.5078125]
Note we always try the destination first, as that is the optimal
shrink.