aboutsummaryrefslogtreecommitdiff
path: root/src/modules/number/index.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-10-14 11:20:20 +0200
committerGitHub <[email protected]>2023-10-14 09:20:20 +0000
commitb4fe307d3394220e5b0ca5e916ae18efad229719 (patch)
tree687faee27aa645a0697ac111df045a799c33796d /src/modules/number/index.ts
parente946e6a651b39d49a884acd9f6468bb18e985bf2 (diff)
downloadfaker-b4fe307d3394220e5b0ca5e916ae18efad229719.tar.xz
faker-b4fe307d3394220e5b0ca5e916ae18efad229719.zip
docs(number): improve documentation regarding number bounds (#2474)
Diffstat (limited to 'src/modules/number/index.ts')
-rw-r--r--src/modules/number/index.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/modules/number/index.ts b/src/modules/number/index.ts
index 9216df7a..87464212 100644
--- a/src/modules/number/index.ts
+++ b/src/modules/number/index.ts
@@ -90,11 +90,13 @@ export class NumberModule {
/**
* Returns a single random floating-point number for a given precision or range and precision.
+ * The lower bound is inclusive, the upper bound is exclusive, unless precision is passed.
*
* @param options Upper bound or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0.0`.
* @param options.max Upper bound for generated number. Defaults to `1.0`.
* @param options.precision Precision of the generated number, for example `0.01` will round to 2 decimal points.
+ * If precision is passed, the upper bound is inclusive.
*
* @example
* faker.number.float() // 0.5688541042618454
@@ -165,6 +167,7 @@ export class NumberModule {
/**
* Returns a [binary](https://en.wikipedia.org/wiki/Binary_number) number.
+ * The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
@@ -213,6 +216,7 @@ export class NumberModule {
/**
* Returns an [octal](https://en.wikipedia.org/wiki/Octal) number.
+ * The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
@@ -261,11 +265,14 @@ export class NumberModule {
/**
* Returns a lowercase [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) number.
+ * The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
* @param options.max Upper bound for generated number. Defaults to `15`.
*
+ * @throws When options define `max < min`.
+ *
* @example
* faker.number.hex() // 'b'
* faker.number.hex(255) // '9d'
@@ -305,6 +312,7 @@ export class NumberModule {
/**
* Returns a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type) number.
+ * The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated bigint. Defaults to `0n`.