From:             alexanderpas at yahoo dot co dot uk
Operating system: All
PHP version:      5.3.0alpha2
PHP Bug Type:     Unknown/Other Function
Bug description:  Incorrect usage of SI-prefixes by PHP

Description:
------------
PHP is handling kilo and other SI prefixes as multiples of 1024.

The SI prefixes should only be used in the decimal sense: kilobyte and
megabyte denote one thousand bytes and one million bytes respectively,
while kibibyte and mebibyte denote 1024 bytes and 1,048,576 bytes
respectively. This recommendation has been adopted by SI, IEEE, CIPM, NIST,
ISO/IEC and some other leading national and international standards, which
now state that the prefixes k, M and G should always refer to powers of
ten, even in the context of information technology. (reference: ISO/IEC IEC
80000-13:2008 )

reduced timeline:
1998:
IEC introduces unambigous prefixes for binary multiples (KiB, MiB, GiB
etc.), reserving kB, MB, GB and so on for their decimal sense.

2005:
IEC prefixes are adopted by the IEEE after a two-year trial period.

2008:
NIST guidelines require use of IEC prefixes KiB, MiB ... (and not kB, MB)
for binary byte multiples

“The names and symbols for the prefixes corresponding to 2 10 , 2 20 , 2
30 , 2 40 , 2 50 , and 2 60 are, respectively: kibi, Ki; mebi, Mi; gibi,
Gi; tebi, Ti; pebi, Pi; and exbi, Ei. Thus, for example, one kibibyte would
be written: 1 KiB = 2 10 B = 1024 B, where B denotes a byte. Although these
prefixes are not part of the SI, they should be used in the field of
information technology to avoid the incorrect usage of the SI prefixes.”

also remember this:
decimal value   binary value    difference      
10001 = 103     10241 = 210     2.4%
10002 = 106     10242 = 220     4.9%
10003 = 109     10243 = 230     7.4%
10004 = 1012    10244 = 240     10.0%
10005 = 1015    10245 = 250     12.6%
10006 = 1018    10246 = 260     15.3%
10007 = 1021    10247 = 270     18.1%
10008 = 1024    10248 = 280     20.9%

also, this has a usability impact, since using the same wording with two
different meanings is JUST PLAIN WRONG, and should end RIGHT NOW, Regular
users don't know that the units have dual meanings, and we shouldn't
continue confusing them in this way.

also "man 7 units" on your linux-box ;)

(please put in correct category!)

Reproduce code:
---------------
<?php
ini_set('memory_limit', '32M');
for ($i=0; $i<=100000000; $i++) {
        $var.="a";
}

Expected result:
----------------
Fatal error: Allowed memory size of 32000000 bytes exhausted (tried to
allocate more bytes) in ./testcase.php on line 4

Actual result:
--------------
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 33292265 bytes) in ./testcase.php on line 4

-- 
Edit bug report at http://bugs.php.net/?id=46534&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46534&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46534&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46534&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46534&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46534&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46534&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46534&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46534&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46534&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46534&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46534&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46534&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46534&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46534&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46534&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46534&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46534&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46534&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46534&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46534&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46534&r=mysqlcfg

Reply via email to