Step Validator uses the unprecise fmod function and fails for floats that are internally represented differently #2597

Closed
zfbot opened this Issue Sep 28, 2012 · 2 comments

Comments

Projects
None yet
3 participants

zfbot commented Sep 28, 2012

Jira Information

Original Issue:ZF2-572
Issue Type:Bug
Reporter:pdobrigkeit
Created:09/19/12
Assignee:weierophinney
Components:Zend\Validator

Description

Giving the step validator a value that cannot be correclty interpreted gives seemingly wrong results in the fmod function.

For example value 15.5, step 0.1 gives a fmod of 0.099999999999999 and not 0.0.

zfbot commented Sep 28, 2012

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF2-572

Known GitHub users mentioned in the original message or comment:
@pdobrigkeit, @weierophinney

Contributor

cgmartin commented Jan 23, 2013

Looks like this may have been resolved in 34e8ab8 , for I was not able to reproduce against master with the following test:

    public function testZf2572()
    {
        $this->_validator->setStep(0.1);
        $this->assertTrue($this->_validator->isValid(15.5));
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment