Zend Framework

0.000000234 << not a float!?

Details

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

Description

<?php
require_once 'Zend/Validate.php';
$float = 0.000000234;

var_dump(Zend_Validate::is($float,'Float'));

// false
<?php
require_once 'Zend/Validate.php';
$float = 1.0000000234;

var_dump(Zend_Validate::is($float,'Float'));

// true
<?php
require_once 'Zend/Validate.php';
$float = 0.000050004;

var_dump(Zend_Validate::is($float,'Float'));

//false
<?php
require_once 'Zend/Validate.php';
$float = 0.005000004;

var_dump(Zend_Validate::is($float,'Float'));

//true

In other words: 100% valid floats are not considered a float.

Activity

Hide
Alexander Veremyev added a comment -

The problem is caused by float numbers recognition within Zend_Locale_Format. E notation is not processed.

0.000050004 and 0.000000234 are transformed into '5.0004E-5' and '2.34E-7' then they passed into Zend_Locale_Format::isFloat()

Show
Alexander Veremyev added a comment - The problem is caused by float numbers recognition within Zend_Locale_Format. E notation is not processed. 0.000050004 and 0.000000234 are transformed into '5.0004E-5' and '2.34E-7' then they passed into Zend_Locale_Format::isFloat()
Hide
Alexander Veremyev added a comment -

Fixed with r14170

Show
Alexander Veremyev added a comment - Fixed with r14170

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: