Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Fix: Do not pick a random float less than minimum #909

Merged
merged 1 commit into from
May 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Faker/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null)

if (null === $max) {
$max = static::randomNumber();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fzaninotto

$max can be 0 here.

if ($min > $max) {
$max = $min;
}
}

if ($min > $max) {
Copy link
Contributor Author

@localheinz localheinz May 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fzaninotto

Without the change proposed in this PR, if $min was originally 0.1, $min would then be set to 0, and eventually the method would return 0, too, in rare cases.

Expand Down