In smlib, Math_Min() returns the biggest of two given numbers and Math_Max() returns the smallest of two given numbers:
|
/** |
|
* Sets the given value to min |
|
* if the value is smaller than the given. |
|
* |
|
* @param value Value |
|
* @param min Min Value used as lower border |
|
* @return Correct value not lower than min |
|
*/ |
|
stock any:Math_Min(any:value, any:min) |
|
{ |
|
if (value < min) { |
|
value = min; |
|
} |
|
|
|
return value; |
|
} |
|
|
|
/** |
|
* Sets the given value to max |
|
* if the value is greater than the given. |
|
* |
|
* @param value Value |
|
* @param max Max Value used as upper border |
|
* @return Correct value not upper than max |
|
*/ |
|
stock any:Math_Max(any:value, any:max) |
|
{ |
|
if (value > max) { |
|
value = max; |
|
} |
|
|
|
return value; |
|
} |
In doing so, they are doing the exact opposite of what anyone who has ever used max and min functions in other languages will expect them to do.
In other programming/scripting languages, the max function returns the maximum value (i.e. the biggest) of a given set and min returns the minimum (the smallest) number of a given set.
I bet that everyone who scripts some SourcePawn and uses the functions provided here will be very confused about the results, then start debugging their code and at some point read the source code of the functions - and then be even more confused about why they are "inverted" and pull their hair out.
In smlib,
Math_Min()returns the biggest of two given numbers andMath_Max()returns the smallest of two given numbers:smlib/scripting/include/smlib/math.inc
Lines 53 to 85 in aad2c8e
In doing so, they are doing the exact opposite of what anyone who has ever used max and min functions in other languages will expect them to do.
In other programming/scripting languages, the max function returns the maximum value (i.e. the biggest) of a given set and min returns the minimum (the smallest) number of a given set.
I bet that everyone who scripts some SourcePawn and uses the functions provided here will be very confused about the results, then start debugging their code and at some point read the source code of the functions - and then be even more confused about why they are "inverted" and pull their hair out.