Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.2
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Locale
  • Labels:
    None

Description

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.

Activity

Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
Vahe Oughourlian added a comment -

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

Show
Vahe Oughourlian added a comment - I'll give that a try. Sorry for the duplicate.
Hide
Vahe Oughourlian added a comment -

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.

Show
Vahe Oughourlian added a comment - 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.
Hide
Vahe Oughourlian added a comment -

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!

Show
Vahe Oughourlian added a comment - 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!
Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
Thomas Weidner added a comment -

Fixed with r15585

Show
Thomas Weidner added a comment - Fixed with r15585

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: