ZF-6060: Zend_Locale_Format::toInteger() fails to work properly with negative input or sufficiently small decimals

Issue Type: Bug Created: 2009-03-18T18:06:37.000+0000 Last Updated: 2009-05-14T14:46:46.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Vahe Oughourlian (jedcred) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments:


Negative numbers are not treated properly by toInteger(). For example, try to format -4.99 to an integer. toInteger returns -3, not -5. However, pass in 4.99, and toInteger does return 5. Looks like an off-by-one error in there somewhere, but I wasn't able to find it by looking for a little while.

Would just like to point out that integers (mathematically speaking) include all natural numbers, zero, and their negative counterparts.


Posted by Thomas Weidner (thomas) on 2009-03-19T00:43:04.000+0000

Looks for me like a duplication of ZF-3473 and ZF-5908 which are already fixed for the next minor release as it's a BC in the results.

If you need a quick fix, simply use Zend_Locale and it's subdirectory from trunk which is the next 1.8 release.

Posted by Vahe Oughourlian (jedcred) on 2009-03-19T10:00:47.000+0000

I'll give that a try. Sorry for the duplicate.

Posted by Vahe Oughourlian (jedcred) on 2009-03-19T12:57:16.000+0000

I went and grabbed the latest version of the Locale directory from the subversion repository. Unfortunately this bug hasn't been fixed in the latest version. Please confirm, in case I've done something wrong. For example, the version of Format.php I'm using is marked version "14261 2009-03-10 11:42:06Z thomas". toInteger(-4.999) still reports -3.

Posted by Vahe Oughourlian (jedcred) on 2009-03-19T21:46:31.000+0000

I'd like to amend this bug; there exists another case where toInteger fails. Try passing into toInteger a very small value, something like 4.26671590503E-6. It returns 4!

Posted by Thomas Weidner (thomas) on 2009-03-19T23:42:12.000+0000

Please add a new issue for the second one. It is very bad practice to have multiple issues within one issue.

A number which is a plain number is a difference than a number with a scientific notation.

And please add an example for reproduction to each issue so that also others, not related to the internals, can see where the problem is.

Posted by Thomas Weidner (thomas) on 2009-05-14T14:46:43.000+0000

Fixed with r15585

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.