PHP 4.0 Bug #2787: max($array) gives wrong values after a while...
| From: | oliver at billix dot franken dot de | Date: | Sun, 21 Nov 1999 15:08:07 +0000 |
| Subject: | PHP 4.0 Bug #2787: max($array) gives wrong values after a while... | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12858@lists.php.net to get a copy of this message | ||
From: oliver@billix.franken.de
Operating system: linux 2.0.38 libc5
PHP version: 4.0 Latest CVS (21/11/1999)
PHP Bug Type: Misbehaving function
Bug description: max($array) gives wrong values after a while...
This short script
<?php
$kbytes = 1024;
$values[0] = 1030264522;
$values[1] = 1292157002;
for ( $i=0 ; $i<count($values) ; $i++ )
print "values[$i] = " . $values[$i] . "\n";
while ( ( $max = max ( $values ) ) > $kbytes ) {
print "max = $max\n";
for ( $i=0 ; $i<count($values) ; $i++ )
if ( isset ( $values[$i] ) ) {
$values[$i] /= $kbytes;
print "values[$i] = " . $values[$i] . "\n";
}
}
print "max = $max\n";
?>
outputs the following values:
values[0] = 1030264522
values[1] = 1292157002
max = 1292157002
values[0] = 1006117.6972656
values[1] = 1261872.0722656
max = 1261872.0722656
values[0] = 982.53681373596
values[1] = 1232.2969455719
max = 1232.2969455719
values[0] = 0.95950860716403
values[1] = 1.2034149859101
max = 0.95950860716403
All but the last max value are correct! (PHP3 gives the correct value)