1 | import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';
|
2 | /**
|
3 | * Constraints to be applied on {@link float}
|
4 | * @remarks Since 2.6.0
|
5 | * @public
|
6 | */
|
7 | export interface FloatConstraints {
|
8 | /**
|
9 | * Lower bound for the generated 32-bit floats (included)
|
10 | * @defaultValue Number.NEGATIVE_INFINITY, -3.4028234663852886e+38 when noDefaultInfinity is true
|
11 | * @remarks Since 2.8.0
|
12 | */
|
13 | min?: number;
|
14 | /**
|
15 | * Should the lower bound (aka min) be excluded?
|
16 | * Note: Excluding min=Number.NEGATIVE_INFINITY would result into having min set to -3.4028234663852886e+38.
|
17 | * @defaultValue false
|
18 | * @remarks Since 3.12.0
|
19 | */
|
20 | minExcluded?: boolean;
|
21 | /**
|
22 | * Upper bound for the generated 32-bit floats (included)
|
23 | * @defaultValue Number.POSITIVE_INFINITY, 3.4028234663852886e+38 when noDefaultInfinity is true
|
24 | * @remarks Since 2.8.0
|
25 | */
|
26 | max?: number;
|
27 | /**
|
28 | * Should the upper bound (aka max) be excluded?
|
29 | * Note: Excluding max=Number.POSITIVE_INFINITY would result into having max set to 3.4028234663852886e+38.
|
30 | * @defaultValue false
|
31 | * @remarks Since 3.12.0
|
32 | */
|
33 | maxExcluded?: boolean;
|
34 | /**
|
35 | * By default, lower and upper bounds are -infinity and +infinity.
|
36 | * By setting noDefaultInfinity to true, you move those defaults to minimal and maximal finite values.
|
37 | * @defaultValue false
|
38 | * @remarks Since 2.8.0
|
39 | */
|
40 | noDefaultInfinity?: boolean;
|
41 | /**
|
42 | * When set to true, no more Number.NaN can be generated.
|
43 | * @defaultValue false
|
44 | * @remarks Since 2.8.0
|
45 | */
|
46 | noNaN?: boolean;
|
47 | /**
|
48 | * When set to true, Number.isInteger(value) will be false for any generated value.
|
49 | * Note: -infinity and +infinity, or NaN can stil be generated except if you rejected them via another constraint.
|
50 | * @defaultValue false
|
51 | * @remarks Since 3.18.0
|
52 | */
|
53 | noInteger?: boolean;
|
54 | }
|
55 | /**
|
56 | * For 32-bit floating point numbers:
|
57 | * - sign: 1 bit
|
58 | * - significand: 23 bits
|
59 | * - exponent: 8 bits
|
60 | *
|
61 | * The smallest non-zero value (in absolute value) that can be represented by such float is: 2 ** -126 * 2 ** -23.
|
62 | * And the largest one is: 2 ** 127 * (1 + (2 ** 23 - 1) / 2 ** 23).
|
63 | *
|
64 | * @param constraints - Constraints to apply when building instances (since 2.8.0)
|
65 | *
|
66 | * @remarks Since 0.0.6
|
67 | * @public
|
68 | */
|
69 | export declare function float(constraints?: FloatConstraints): Arbitrary<number>;
|