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


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.


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.

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

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.

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!

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.

Fixed with r15585