[Fixed] Min() and Max() always returns double (POL097-2008-02-26
Posted: Sun Mar 09, 2008 9:08 pm
Regardless of the types of the variables passed in function Min() or Max(), the value returned is always double.
Using following code you can see it by yourself.
Also the documentations have errors in it, as the mentioned functions are told to return integer.
This is very annoying bug because before this release, we already had our own Min and Max functions that worked correctly, and because of this bug we should have integer conversations in places never needed it before, resulting weird behaviour in some scripts.
As a feature request I wish Min() and Max() would not change the type of the larger or smaller value at all: so if 0 (integer) and 2.2 (double) is passed to Max(), it would return 2.2 (double), and if they are passed in Min(), it would return 0 (integer).
Using following code you can see it by yourself.
Code: Select all
var x := 1;
var y := 2;
Print("Type of x: " + TypeOf(x) + ", type of y: " + TypeOf(y)); // -> integer, integer
var maxxy := Max(x, y);
var minxy := Min(x, y);
Print("Return value of maxxy: " + maxxy + ", type of maxxy: " + TypeOf(maxxy)); // -> 2, double
Print("Return value of minxy: " + minxy + ", type of minxy: " + TypeOf(minxy)); // -> 1, double
This is very annoying bug because before this release, we already had our own Min and Max functions that worked correctly, and because of this bug we should have integer conversations in places never needed it before, resulting weird behaviour in some scripts.
As a feature request I wish Min() and Max() would not change the type of the larger or smaller value at all: so if 0 (integer) and 2.2 (double) is passed to Max(), it would return 2.2 (double), and if they are passed in Min(), it would return 0 (integer).