Larger and Smaller Operators: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
'''Supported platforms:''' android, ios, mac, pc<br/>
'''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/>
'''Available since:''' Gideros 2017.10<br/>
=== Description ===
=== Description ===
<br />
Operators to return the larger or smaller of two values.
Operators to return the larger or smaller of two values.<br /><br />
 
a'''<>'''b, compares 'a' and 'b', returns the larger of them
 
a'''><'''b, compares 'a' and 'b', returns the smaller of them


a<b> &lt;&gt; </b>b &emsp; Compare 'a' and 'b', return the larger of them.<br />
a<b> &gt;&lt; </b>b &emsp; Compare 'a' and 'b', return the smaller of them.<br />
=== Examples ===
=== Examples ===
'''Simple larger examples'''<br/>
'''Simple larger examples'''
<source lang="lua"><br />  
<syntaxhighlight lang="lua">
x=a&lt;&gt;b -- faster than x=math.max(a,b)
x=a<>b -- faster than x=math.max(a,b)
x=(x-1)&lt;&gt;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'''<br/>
</syntaxhighlight>
<source lang="lua"><br />  
 
x=a&gt;&lt;b -- faster than x=math.min(a,b)
'''Simple smaller examples'''
x=(x+1)&gt;&lt;15 -- increment x, but don't go above 15</source>
<syntaxhighlight lang="lua">
'''Make sure x is within bounds example'''<br/>
x=a><b -- faster than x=math.min(a,b)
<source lang="lua"><br />  
x=(x+1)><15 -- increment x, but don't go above 15
x=(x&lt;&gt;min)&gt;&lt;max</source>
</syntaxhighlight>
'''Always return the negative of a number'''<br/>
 
<source lang="lua"><br />  
'''Make sure x is within bounds example'''
x=-x&gt;&lt;x -- faster than -math.abs</source>
<syntaxhighlight lang="lua">
'''Always return the positive of a number'''<br/>
x=(x<>min)><max
<source lang="lua"><br />  
</syntaxhighlight>
x=-x&lt;&gt;x -- faster than math.abs</source>
 
{|-
'''Always return the negative of a number'''
| style="width: 50%;"|
<syntaxhighlight lang="lua">
=== Methods ===
x=-x><x -- faster than -math.abs
| style="width: 50%;"|
</syntaxhighlight>
=== Events ===
 
=== Constants ===
'''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 22:47, 13 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