AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Some info about min() and max() (https://forums.alliedmods.net/showthread.php?t=245026)

Flick3rR 07-27-2014 08:13

Some info about min() and max()
 
Hey, guys! I couldn't find an info around the internet about these two natives. So, I know what they both should return, but the problem is that I don't know which one which value returns. I mean, does max(5+1, 5) will return 5, or it will return 6. And does max(4, 5) return 5 or 4? The same about min().
I found they are just natives from the core.inc, but no info.
Just that, thanks in advance!

YamiKaitou 07-27-2014 08:15

Re: Some info about min() and max()
 
min will return whatever value is the lowest
max will return whatever value is the highest

Flick3rR 07-27-2014 08:37

Re: Some info about min() and max()
 
Understood it. I made this thread, because I wanted to understand if I can use these natives as one-side clamp() function. The answer is yes. Thanks for the info!
What can I explain shortly:
You can use max() to make a border, which a value can't go lower. Like if you want your value to not get under the zero, you make it like:
PHP Code:

max(MyValue0

The opposite applies to min(). Your value won't go above the value in this native:
PHP Code:

min(MyValue0

In this way, your value will never be possitive.
Thanks for the info!

mottzi 07-27-2014 08:42

Re: Some info about min() and max()
 
min returns the parameter with the lower value.
max returns the parameter with the higher value.

Flick3rR 07-27-2014 08:46

Re: Some info about min() and max()
 
Yeah, I got it. Just explained what I could understand to someone else, who searches for such an info. These two replies may be deleted, I think.

hornet 07-27-2014 09:53

Re: Some info about min() and max()
 
Quote:

Originally Posted by Flick3rR (Post 2174584)
These two replies may be deleted, I think.

The forum administration uphold a strict no-information-deletion policy.


All times are GMT -4. The time now is 13:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.