[wp-trac] [WordPress Trac] #19067: Duplicate functionality in core: size_format() and wp_convert_bytes_to_hr()

WordPress Trac noreply at wordpress.org
Tue Feb 26 08:35:59 UTC 2013


#19067: Duplicate functionality in core: size_format() and wp_convert_bytes_to_hr()
----------------------------------------+-----------------------------
 Reporter:  l3rady                      |       Owner:  SergeyBiryukov
     Type:  enhancement                 |      Status:  closed
 Priority:  normal                      |   Milestone:  3.6
Component:  General                     |     Version:  3.2.1
 Severity:  trivial                     |  Resolution:  fixed
 Keywords:  has-patch 3.6-early commit  |
----------------------------------------+-----------------------------

Comment (by soulseekah):

 Two issues: on 64-bit PHP (`PHP_INT_SIZE == 8`) floating point does not
 match expected output (gets `1022.9990234375MB`). The last digits in
 floating point should not be depended upon due to these inaccuracies.
 Rounding in PHP < 5.3 is not an option either, since rounding `mode` was
 introduced later and different systems get different results (round up vs.
 round down by default). So perhaps looking at error and discrepancy would
 be a decent solution (maybe even less error 0.00001?).

 And `wp_convert_bytes_to_hr`'s `(int)double(NAN)` result from feeding -1
 and 0 results in power being a huge negative number instead of 0. This
 results in both a Warning being thrown, and the "B" missing in tests, i.e.
 expected "NANB" != "NAN" and expected "0B" != "0".

 Tests pass with patches applied.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19067#comment:30>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list