NeoFaker.Number (neo_faker v0.11.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
.
Returns a random integer if both arguments are integers, or a random float if either argument is a float. Defaults to the range 0 to 100 if no arguments are provided.
Examples
iex> NeoFaker.Number.between()
27
iex> NeoFaker.Number.between(1, 100)
28
iex> NeoFaker.Number.between(20, 100.0)
29.481745280074264
iex> NeoFaker.Number.between(10.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