Bug #3166: max() function doesn't convert types right
| From: | mdobel at kawo2 dot rwth-aachen dot de | Date: | Mon, 10 Jan 2000 23:19:53 +0000 |
| Subject: | Bug #3166: max() function doesn't convert types right | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14478@lists.php.net to get a copy of this message | ||
From: mdobel@kawo2.rwth-aachen.de
Operating system: Linux 2.1.12 (Redhat 6.1)
PHP version: 3.0.13
PHP Bug Type: Misbehaving function
Bug description: max() function doesn't convert types right
i fetch the maximum of a mysql column which is defined as float, then compare it with a
"minimum maximum" defined before (it's for scaling purposes, i don't want the
y-axis be shorter than $min_y).
$min_y=1000;
$sql_query=mysql_query("SELECT max(".$ycol.") FROM ".$table);
$row=mysql_fetch_row($sql_query);
$maxval=max($row[0],$min_y);
the max function always returns $row[0], even if it's (in this special case) 195,04 and $maxval
is 1000.
workaround:
$maxval=max((double)$row[0],$min_y);
but i think, this is wrong behaviour.