Difference between revisions of "Larger and Smaller Operators"
From GiderosMobile
| (9 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
| − | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform linux.png]]<br/> |
| − | ''' | + | '''Available since:''' Gideros 2017.10<br/> |
| − | |||
| − | |||
| − | |||
| − | a< | + | === Description === |
| − | a | + | Operators to return the larger or smaller of two values. |
| − | === | + | |
| − | '''Simple larger examples''' | + | a'''<>'''b, compares 'a' and 'b', returns the larger of them |
| − | < | + | |
| − | x=a | + | a'''><'''b, compares 'a' and 'b', returns the smaller of them |
| − | x=(x-1) | + | |
| − | '''Simple smaller examples''' | + | === Examples === |
| − | < | + | '''Simple larger examples''' |
| − | x=a | + | <syntaxhighlight lang="lua"> |
| − | x=(x+1) | + | x=a<>b -- faster than x=math.max(a,b) |
| − | '''Make sure x is within bounds example''' | + | x=(x-1)<>5 -- decrement x, but don't go below 5 |
| − | < | + | </syntaxhighlight> |
| − | x=(x | + | |
| − | '''Always return the negative of a number''' | + | '''Simple smaller examples''' |
| − | < | + | <syntaxhighlight lang="lua"> |
| − | x=-x | + | x=a><b -- faster than x=math.min(a,b) |
| − | '''Always return the positive of a number''' | + | x=(x+1)><15 -- increment x, but don't go above 15 |
| − | < | + | </syntaxhighlight> |
| − | x=-x | + | |
| − | + | '''Make sure x is within bounds example''' | |
| − | + | <syntaxhighlight lang="lua"> | |
| − | + | x=(x<>min)><max | |
| − | + | </syntaxhighlight> | |
| − | + | ||
| − | + | '''Always return the negative of a number''' | |
| − | + | <syntaxhighlight lang="lua"> | |
| + | x=-x><x -- faster than -math.abs | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | '''Always return the positive of a number''' | ||
| + | <syntaxhighlight lang="lua"> | ||
| + | x=-x<>x -- faster than math.abs | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | {{GIDEROS IMPORTANT LINKS}} | ||
Latest revision as of 00:47, 14 January 2025
Supported platforms: ![]()
![]()
![]()
![]()
![]()
Available since: Gideros 2017.10
Description
Operators to return the larger or smaller of two values.
a<>b, compares 'a' and 'b', returns the larger of them
a><b, compares 'a' and 'b', returns the smaller of them
Examples
Simple larger examples
x=a<>b -- faster than x=math.max(a,b)
x=(x-1)<>5 -- decrement x, but don't go below 5
Simple smaller examples
x=a><b -- faster than x=math.min(a,b)
x=(x+1)><15 -- increment x, but don't go above 15
Make sure x is within bounds example
x=(x<>min)><max
Always return the negative of a number
x=-x><x -- faster than -math.abs
Always return the positive of a number
x=-x<>x -- faster than math.abs