Difference between revisions of "Larger and Smaller Operators"
From GiderosMobile
(removed language stuff plus formatting) |
|||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
| − | |||
<!-- GIDEROSOBJ:Larger and Smaller Operators --> | <!-- GIDEROSOBJ:Larger and Smaller Operators --> | ||
| − | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.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. |
| − | <source lang="lua"> | + | |
| + | a'''><'''b   compares 'a' and 'b', returns the smaller of them. | ||
| + | |||
| + | === Examples === | ||
| + | '''Simple larger examples''' | ||
| + | <source lang="lua"> | ||
x=a<>b -- faster than x=math.max(a,b) | x=a<>b -- faster than x=math.max(a,b) | ||
| − | x=(x-1)<>5 -- decrement x, but don't go below 5</source> | + | x=(x-1)<>5 -- decrement x, but don't go below 5 |
| − | '''Simple smaller examples''' | + | </source> |
| − | <source lang="lua"> | + | |
| + | '''Simple smaller examples''' | ||
| + | <source lang="lua"> | ||
x=a><b -- faster than x=math.min(a,b) | x=a><b -- faster than x=math.min(a,b) | ||
| − | x=(x+1)><15 -- increment x, but don't go above 15</source> | + | x=(x+1)><15 -- increment x, but don't go above 15 |
| − | '''Make sure x is within bounds example''' | + | </source> |
| − | <source lang="lua"> | + | |
| − | x=(x<>min)><max</source> | + | '''Make sure x is within bounds example''' |
| − | '''Always return the negative of a number''' | + | <source lang="lua"> |
| − | <source lang="lua"> | + | x=(x<>min)><max |
| − | x=-x><x -- faster than -math.abs</source> | + | </source> |
| − | '''Always return the positive of a number''' | + | |
| − | <source lang="lua"> | + | '''Always return the negative of a number''' |
| − | x=-x<>x -- faster than math.abs</source> | + | <source lang="lua"> |
| + | x=-x><x -- faster than -math.abs | ||
| + | </source> | ||
| + | |||
| + | '''Always return the positive of a number''' | ||
| + | <source lang="lua"> | ||
| + | x=-x<>x -- faster than math.abs | ||
| + | </source> | ||
| + | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
| − | === | + | === Methods === |
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
| − | === | + | === Events === |
| − | === | + | === Constants === |
|} | |} | ||
{{GIDEROS IMPORTANT LINKS}} | {{GIDEROS IMPORTANT LINKS}} | ||
Revision as of 03:54, 10 October 2021
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
Methods |
EventsConstants |