Raised This Month: $ Target: $400
 0% 

Some info about min() and max()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-27-2014 , 08:13   Some info about min() and max()
Reply With Quote #1

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!
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-27-2014 , 08:15   Re: Some info about min() and max()
Reply With Quote #2

min will return whatever value is the lowest
max will return whatever value is the highest
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-27-2014 , 08:37   Re: Some info about min() and max()
Reply With Quote #3

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!
__________________

Last edited by Flick3rR; 07-27-2014 at 08:45.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-27-2014 , 08:42   Re: Some info about min() and max()
Reply With Quote #4

min returns the parameter with the lower value.
max returns the parameter with the higher value.
mottzi is offline
Send a message via MSN to mottzi
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-27-2014 , 08:46   Re: Some info about min() and max()
Reply With Quote #5

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.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-27-2014 , 09:53   Re: Some info about min() and max()
Reply With Quote #6

Quote:
Originally Posted by Flick3rR View Post
These two replies may be deleted, I think.
The forum administration uphold a strict no-information-deletion policy.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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