Skip to main content

number Domain

The number domain maps domain keywords to underlying faker implementations.

Faker Documentation

Methods

number.bigInt

Returns a BigInt number.

ArgTypeRequiredDescription
valuebigint|number|string|booleannoBase value used for generation. Supports bigint, number, string, or boolean inputs. For range constraints use min, max, and multipleOf.

Examples:

number.bigInt()
number.bigInt(value="value")

Example return values:

  • 347465151663036

number.binary

Returns a binary string.

ArgTypeRequiredDescription
maxnumbernoUpper bound for generated number.
minnumbernoLower bound for generated number.

Examples:

number.binary()
number.binary(max=1, min=1)

Example return values:

  • 0

number.float

Returns a single random floating-point number, by default between 0.0 and 1.0. To change the range, pass a min and max value. To limit the number of decimal places, pass a multipleOf or fractionDigits parameter.

ArgTypeRequiredDescription
fractionDigitsintegernoThe maximum number of digits to appear after the decimal point, for example 2 will round to 2 decimal points. Only one of multipleOf or fractionDigits should be passed.
maxnumbernoUpper bound for generated number, exclusive, unless multipleOf or fractionDigits are passed.
minnumbernoLower bound for generated number, inclusive.
multipleOfnumbernoThe generated number will be a multiple of this parameter. Only one of multipleOf or fractionDigits should be passed.

Examples:

number.float()

Type-in examples (named params):

number.float(max=1)
number.float(min=1)
number.float(multipleOf=1)

Example return values:

  • 0.5433707701438405

number.hex

Returns a lowercase hexadecimal number.

ArgTypeRequiredDescription
minnumbernoMinimum bound used when generating a value.
maxnumbernoMaximum bound used when generating a value.

Examples:

number.hex()
number.hex(min=1, max=1)

Example return values:

  • d

number.int

Returns a single random integer between zero and the given max value or the given range.

ArgTypeRequiredDescription
minnumbernoOptional minimum integer.
maxnumbernoOptional maximum integer.
multipleOfnumbernoGenerated number will be a multiple of the given integer.

Examples:

number.int()
number.int(min=1, max=1, multipleOf=1)

Example return values:

  • 5190574431878510

number.octal

Returns an octal string.

ArgTypeRequiredDescription
maxnumbernoUpper bound for generated number.
minnumbernoLower bound for generated number.

Examples:

number.octal()
number.octal(max=1, min=1)

Example return values:

  • 6

number.romanNumeral

Returns a roman numeral in String format.

ArgTypeRequiredDescription
minnumbernoMinimum bound used when generating a value.
maxnumbernoMaximum bound used when generating a value.

Examples:

number.romanNumeral()
number.romanNumeral(min=1, max=1)

Example return values:

  • XXXV