Difference between revisions of "Larger and Smaller Operators"

From GiderosMobile
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
<!-- GIDEROSOBJ:Larger and Smaller Operators -->
+
'''Available since:''' Gideros 2017.10<br/>
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2017.10<br/>
 
=== <translate>Description</translate> ===
 
<translate><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 />
+
=== Description ===
a<b> &gt;&lt; </b>b &emsp; Compare 'a' and 'b', return the smaller of them.<br /></translate>
+
Operators to return the larger or smaller of two values.
=== <translate>Examples</translate> ===
+
 
'''Simple larger examples'''<br/>
+
a'''<>'''b, compares 'a' and 'b', returns the larger of them
<source lang="lua">  
+
 
x=a&lt;&gt;b -- faster than x=math.max(a,b)
+
a'''><'''b, compares 'a' and 'b', returns the smaller of them
x=(x-1)&lt;&gt;5 -- decrement x, but don't go below 5</source>
+
 
'''Simple smaller examples'''<br/>
+
=== Examples ===
<source lang="lua">  
+
'''Simple larger examples'''
x=a&gt;&lt;b -- faster than x=math.min(a,b)
+
<syntaxhighlight lang="lua">
x=(x+1)&gt;&lt;15 -- increment x, but don't go above 15</source>
+
x=a<>b -- faster than x=math.max(a,b)
'''Make sure x is within bounds example'''<br/>
+
x=(x-1)<>5 -- decrement x, but don't go below 5
<source lang="lua">  
+
</syntaxhighlight>
x=(x&lt;&gt;min)&gt;&lt;max</source>
+
 
'''Always return the negative of a number'''<br/>
+
'''Simple smaller examples'''
<source lang="lua">  
+
<syntaxhighlight lang="lua">
x=-x&gt;&lt;x -- faster than -math.abs</source>
+
x=a><b -- faster than x=math.min(a,b)
'''Always return the positive of a number'''<br/>
+
x=(x+1)><15 -- increment x, but don't go above 15
<source lang="lua">  
+
</syntaxhighlight>
x=-x&lt;&gt;x -- faster than math.abs</source>
+
 
{|-
+
'''Make sure x is within bounds example'''
| style="width: 50%; vertical-align:top;"|
+
<syntaxhighlight lang="lua">
=== <translate>Methods</translate> ===
+
x=(x<>min)><max
| style="width: 50%; vertical-align:top;"|
+
</syntaxhighlight>
=== <translate>Events</translate> ===
+
 
=== <translate>Constants</translate> ===
+
'''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 03:59, 1 December 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png
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