Difference between revisions of "Larger and Smaller Operators"

From GiderosMobile
Line 3: Line 3:
 
'''Available since:''' Gideros 2017.10<br/>
 
'''Available since:''' Gideros 2017.10<br/>
 
=== Description ===
 
=== Description ===
<br />
+
<translate><br />
 
Operators to return the larger or smaller of two values.<br /><br />
 
Operators to return the larger or smaller of two values.<br /><br />
  
 
a<b> &lt;&gt; </b>b &emsp; Compare 'a' and 'b', return the larger of them.<br />
 
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 />
+
a<b> &gt;&lt; </b>b &emsp; Compare 'a' and 'b', return the smaller of them.<br /></translate>
 
=== Examples ===
 
=== Examples ===
 
'''Simple larger examples'''<br/>
 
'''Simple larger examples'''<br/>
<source lang="lua"><br />  
+
<source lang="lua">  
 
x=a&lt;&gt;b -- faster than x=math.max(a,b)
 
x=a&lt;&gt;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)&lt;&gt;5 -- decrement x, but don't go below 5</source>
 
'''Simple smaller examples'''<br/>
 
'''Simple smaller examples'''<br/>
<source lang="lua"><br />  
+
<source lang="lua">  
 
x=a&gt;&lt;b -- faster than x=math.min(a,b)
 
x=a&gt;&lt;b -- faster than x=math.min(a,b)
 
x=(x+1)&gt;&lt;15 -- increment x, but don't go above 15</source>
 
x=(x+1)&gt;&lt;15 -- increment x, but don't go above 15</source>
 
'''Make sure x is within bounds example'''<br/>
 
'''Make sure x is within bounds example'''<br/>
<source lang="lua"><br />  
+
<source lang="lua">  
 
x=(x&lt;&gt;min)&gt;&lt;max</source>
 
x=(x&lt;&gt;min)&gt;&lt;max</source>
 
'''Always return the negative of a number'''<br/>
 
'''Always return the negative of a number'''<br/>
<source lang="lua"><br />  
+
<source lang="lua">  
 
x=-x&gt;&lt;x -- faster than -math.abs</source>
 
x=-x&gt;&lt;x -- faster than -math.abs</source>
 
'''Always return the positive of a number'''<br/>
 
'''Always return the positive of a number'''<br/>
<source lang="lua"><br />  
+
<source lang="lua">  
 
x=-x&lt;&gt;x -- faster than math.abs</source>
 
x=-x&lt;&gt;x -- faster than math.abs</source>
 
{|-
 
{|-

Revision as of 14:34, 23 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2017.10

Description


Operators to return the larger or smaller of two values.

a <> b   Compare 'a' and 'b', return the larger of them.
a >< b   Compare 'a' and 'b', return the smaller of them.

Examples

Simple larger examples

 
x=a&lt;&gt;b -- faster than x=math.max(a,b)
x=(x-1)&lt;&gt;5 -- decrement x, but don't go below 5

Simple smaller examples

 
x=a&gt;&lt;b -- faster than x=math.min(a,b)
x=(x+1)&gt;&lt;15 -- increment x, but don't go above 15

Make sure x is within bounds example

 
x=(x&lt;&gt;min)&gt;&lt;max

Always return the negative of a number

 
x=-x&gt;&lt;x -- faster than -math.abs

Always return the positive of a number

 
x=-x&lt;&gt;x -- faster than math.abs

Methods

Events

Constants