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

Replace PHP internal fmod function because it gives false negatives #2387

Closed
wants to merge 2 commits into from

Conversation

pdobrigkeit
Copy link
Contributor

fmod is unsafe to use, because for floats that are internally represented differently it give results like 0.00099999997 or something. I used one of the replacement functions found on the PHP manual as a quick fix

if($y == 0.0) {
return 1.0;
}
return $x-$y*floor($x/$y);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add spaces between operators, not sure this will pass CS

weierophinney added a commit that referenced this pull request Sep 19, 2012
weierophinney added a commit that referenced this pull request Sep 19, 2012
@weierophinney
Copy link
Member

I fixed the remaining CS issues on merge. Thanks!

@ghost ghost assigned weierophinney Sep 19, 2012
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants