Page 1 of 1

[Fixed] Min() and Max() always returns double (POL097-2008-02-26

Posted: Sun Mar 09, 2008 9:08 pm
by ncrsn
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.

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
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).

Posted: Mon Mar 10, 2008 10:11 am
by Demostenes
The newest release is one big surprise. There was much more changes, than is written in change.log, so since release, we are still discovering, how much things stopped working and why.
For exaxmple yesterday we were fixing some problem and to 4 o'clock in the morning trying to discover, why our in-game html help stopped working properly since new core. After some time, we found out, that there some forbidden chars in unpack function (or more precisely aux connection)
now.....
I have nothing against changes, but they should be documented.

Posted: Tue Mar 11, 2008 12:47 am
by ncrsn
"[Changes] should be documented."
So should be the bugs.

I bet there are many core bugs discovered times ago that are either never reported or just forgotten because of a new core release.

Posted: Tue Mar 11, 2008 1:06 am
by CWO
You might even see it in your own scripts sometimes too... Changing certain things might affect other things on your shard even if they seem unrelated to your players. Only you would know if you knew your scriptbase completely how they would be related. Same thing can happen with core devs developing the core.

Re: Min() and Max() always returns double (POL097-2008-02-26)

Posted: Tue Dec 30, 2008 10:36 am
by MuadDib

Code: Select all

08-28 Turley:
        Fixed : math::Min()/Max() now returns Integer/Double based on params