Faker C++
Loading...
Searching...
No Matches
faker::datatype Namespace Reference

Functions

FAKER_CXX_EXPORT bool boolean ()
 Returns a random boolean.
 
FAKER_CXX_EXPORT bool boolean (double probability)
 Returns a random boolean. **Note:** A probability of `0.75` results in `true` being returned `75%` of the calls; likewise `0.3` => `30%`. If the probability is `<= 0.0`, it will always return `false`. If the probability is `>= 1.0`, it will always return `true`. The probability is limited to two decimal places.
 

Function Documentation

◆ boolean() [1/2]

FAKER_CXX_EXPORT bool faker::datatype::boolean ( )

Returns a random boolean.

Returns
Boolean.
FAKER_CXX_EXPORT bool boolean()
Returns a random boolean.

◆ boolean() [2/2]

FAKER_CXX_EXPORT bool faker::datatype::boolean ( double probability)

Returns a random boolean. **Note:** A probability of `0.75` results in `true` being returned `75%` of the calls; likewise `0.3` => `30%`. If the probability is `<= 0.0`, it will always return `false`. If the probability is `>= 1.0`, it will always return `true`. The probability is limited to two decimal places.

Parameters
probabilityThe probability (`[0.00, 1.00]`) of returning `true`.
Returns
Boolean.
faker::datatype::boolean(0.9) // "true"
faker::datatype::boolean(0.1) // "false"
Definition airline.h:9