Min: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>Eliteofdelete No edit summary |
||
Line 28: | Line 28: | ||
function_description=Compares two numbers, and returns the lower of the two. Note that it is possible to mix an int and float type in the parameters, in which case the int parameter will be transparently converted to a float, and the value returned will be of float type.| | function_description=Compares two numbers, and returns the lower of the two. Note that it is possible to mix an int and float type in the parameters, in which case the int parameter will be transparently converted to a float, and the value returned will be of float type.| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Simple example using min to determine how many twinkly wads you can currently use based on the amount on hand and your spleen limit.| | |||
code= | |||
<syntaxhighlight> | |||
int amount = min(item_amount($item[twinkly wad]), spleen_limit() - my_spleen_use()); | |||
print("You can currently use "+amount+" twinkly wads.", "blue"); | |||
</syntaxhighlight>| | |||
}}| | |||
see_also={{SeeAlso|max}}| | see_also={{SeeAlso|max}}| | ||
}} | }} | ||
[[Category:Math and Numbers]] | [[Category:Math and Numbers]] |
Latest revision as of 22:22, 21 January 2015
Function Syntax
- a is the first number to compare
- b is the second number to compare
Compares two numbers, and returns the lower of the two. Note that it is possible to mix an int and float type in the parameters, in which case the int parameter will be transparently converted to a float, and the value returned will be of float type.
Code Samples
Simple example using min to determine how many twinkly wads you can currently use based on the amount on hand and your spleen limit.
int amount = min(item_amount($item[twinkly wad]), spleen_limit() - my_spleen_use());
print("You can currently use "+amount+" twinkly wads.", "blue");