Skip to content

Commit b4fe307

Browse files
authored
docs(number): improve documentation regarding number bounds (#2474)
1 parent e946e6a commit b4fe307

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/modules/number/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ export class NumberModule {
9090

9191
/**
9292
* Returns a single random floating-point number for a given precision or range and precision.
93+
* The lower bound is inclusive, the upper bound is exclusive, unless precision is passed.
9394
*
9495
* @param options Upper bound or options object. Defaults to `{}`.
9596
* @param options.min Lower bound for generated number. Defaults to `0.0`.
9697
* @param options.max Upper bound for generated number. Defaults to `1.0`.
9798
* @param options.precision Precision of the generated number, for example `0.01` will round to 2 decimal points.
99+
* If precision is passed, the upper bound is inclusive.
98100
*
99101
* @example
100102
* faker.number.float() // 0.5688541042618454
@@ -165,6 +167,7 @@ export class NumberModule {
165167

166168
/**
167169
* Returns a [binary](https://en.wikipedia.org/wiki/Binary_number) number.
170+
* The bounds are inclusive.
168171
*
169172
* @param options Maximum value or options object. Defaults to `{}`.
170173
* @param options.min Lower bound for generated number. Defaults to `0`.
@@ -213,6 +216,7 @@ export class NumberModule {
213216

214217
/**
215218
* Returns an [octal](https://en.wikipedia.org/wiki/Octal) number.
219+
* The bounds are inclusive.
216220
*
217221
* @param options Maximum value or options object. Defaults to `{}`.
218222
* @param options.min Lower bound for generated number. Defaults to `0`.
@@ -261,11 +265,14 @@ export class NumberModule {
261265

262266
/**
263267
* Returns a lowercase [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) number.
268+
* The bounds are inclusive.
264269
*
265270
* @param options Maximum value or options object. Defaults to `{}`.
266271
* @param options.min Lower bound for generated number. Defaults to `0`.
267272
* @param options.max Upper bound for generated number. Defaults to `15`.
268273
*
274+
* @throws When options define `max < min`.
275+
*
269276
* @example
270277
* faker.number.hex() // 'b'
271278
* faker.number.hex(255) // '9d'
@@ -305,6 +312,7 @@ export class NumberModule {
305312

306313
/**
307314
* Returns a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type) number.
315+
* The bounds are inclusive.
308316
*
309317
* @param options Maximum value or options object. Defaults to `{}`.
310318
* @param options.min Lower bound for generated bigint. Defaults to `0n`.

0 commit comments

Comments
 (0)