NeoFaker.Number (neo_faker v0.10.0)
View SourceFunctions for generating random numbers.
This module provides utilities to generate random numbers, including values within a specified range.
Summary
Functions
Generates a random number between min
and max
.
Generates a random digit between 0
and 9
.
Generates a random floating-point number within the given range.
Functions
Generates a random number between min
and max
.
If both arguments are integers, the result is a random integer within the range. If they are floats, a random float within the range is returned.
Examples
iex> NeoFaker.Number.between()
27
iex> NeoFaker.Number.between(1, 100)
28
iex> NeoFaker.Number.between(1.0, 100.0)
29.481745280074264
@spec digit() :: integer()
Generates a random digit between 0
and 9
.
Examples
iex> NeoFaker.Number.digit()
5
Generates a random floating-point number within the given range.
The integer part is selected from left_digit
, and the fractional part from right_digit
.
Both arguments are ranges, and the function returns a float by combining a random value from
each.
Examples
iex> NeoFaker.Number.float()
30.94372
iex> NeoFaker.Number.float(1..9, 10..90)
1.44