php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2787 max($array) gives wrong values after a while...
Submitted: 1999-11-21 16:08 UTC Modified: 1999-11-21 18:13 UTC
From: oliver at billix dot franken dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Latest CVS (21/11/1999) OS: linux 2.0.38 libc5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oliver at billix dot franken dot de
New email:
PHP Version: OS:

 

 [1999-11-21 16:08 UTC] oliver at billix dot franken dot de
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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-21 18:13 UTC] thies at cvs dot php dot net
fixed in CVS. thanx.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 13:00:01 2026 UTC