"math" Snippets


Basket #63068

 date  math
Get the formatted date one week from now.
Created: 1512430270
View "Basket #63068"
<mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantList_Load_Product( l.settings:product:id, l.settings:product:variants )" />
 

Basket #70030

 date  math
Get the formatted date one week from now.
Created: 1512005140
View "Basket #70030"
<mvt:assign name="g.foo" value="'bar'" /> &mvte:global:foo;
 

Basket #67233

 date  math
Get the formatted date one week from now.
Created: 1508948888
View "Basket #67233"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 395" /> <mvt:assign name="g.one_month" value="60 * 60 * 24 * 30" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> <mvt:assign name="g.time_teste" value="g.future_time - g.current_time"/> <mvt:assign name="g.teste_month" value="floor(g.time_teste/g.one_month)" /> &mvt:global:formatted_future_date; <br> &mvt:global:teste_month;
 

Basket #66538

 date  math
Get the formatted date one week from now.
Created: 1508338358
View "Basket #66538"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 7" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> &mvt:global:formatted_future_date;
 

Basket #56665

 math
Created: 1503680577
View "Basket #56665"
<mvt:assign name="l.settings:roundme" value="8.95" /> <mvt:eval expr="l.settings:roundme ROUND 0" /><br/> <mvt:do name="l.result" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, 1.25 )" />
 

Basket #42796

 date  math
Get the formatted date one week from now.
Created: 1494283731
View "Basket #42796"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 7" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> &mvt:global:formatted_future_date;<br/> &mvt:global:future_time;
 

Tiered Quantities

 math
Created: 1489685840
View "Tiered Quantities"
<mvt:assign name="g.Quantity" value="1049" /> <mvt:assign name="g.Tier" value="1000" /> g.Quantity=&mvte:global:Quantity;<br> g.Tier=&mvte:global:Tier;<br> <h2>// Division & Ceil/Floor</h2> <mvt:assign name="g.Quantity_Rounded_Up" value="ceil(g.Quantity / g.Tier) * g.Tier" /> g.Quantity_Rounded_Up=&mvte:global:Quantity_Rounded_Up;<br> <mvt:assign name="g.Quantity_Rounded_Down" value="floor(g.Quantity / g.Tier) * g.Tier" /> g.Quantity_Rounded_Down=&mvte:global:Quantity_Rounded_Down;<br> <mvt:comment> <!-- <h2>// MOD</h2> <mvt:assign name="g.Remainder" value="g.Quantity MOD g.Tier" /> g.Remainder=&mvte:global:Remainder;<br> <mvt:assign name="g.Rounded_Quantity" value="g.Quantity - g.Remainder" /> g.Rounded_Quantity=&mvte:global:Rounded_Quantity;<br> <mvt:assign name="g.Final_Quantity" value="g.Rounded_Quantity + g.Tier" /> g.Final_Quantity=&mvte:global:Final_Quantity;<br> --> </mvt:comment>
 

Tiered Quantities

 math
Created: 1489685556
View "Tiered Quantities"
<mvt:assign name="g.Quantity" value="1049" /> <mvt:assign name="g.Tier" value="1000" /> g.Quantity=&mvte:global:Quantity;<br> g.Tier=&mvte:global:Tier;<br> <h2>// Division & Ceil/Floor</h2> <mvt:assign name="g.Quantity_Rounded_Up" value="ceil(g.Quantity / g.Tier) * g.Tier" /> g.Quantity_Rounded_Up=&mvte:global:Quantity_Rounded_Up;<br> <mvt:assign name="g.Quantity_Rounded_Down" value="floor(g.Quantity / g.Tier) * g.Tier" /> g.Quantity_Rounded_Down=&mvte:global:Quantity_Rounded_Down;<br> <mvt:comment> <h2>// MOD</h2> <mvt:assign name="g.Remainder" value="g.Quantity MOD g.Tier" /> g.Remainder=&mvte:global:Remainder;<br> <mvt:assign name="g.Rounded_Quantity" value="g.Quantity - g.Remainder" /> g.Rounded_Quantity=&mvte:global:Rounded_Quantity;<br> <mvt:assign name="g.Final_Quantity" value="g.Rounded_Quantity + g.Tier" /> g.Final_Quantity=&mvte:global:Final_Quantity;<br> </mvt:comment>
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456865839
View "MivaScript Operators"
<h1>MivaScript Operator Examples</h1> <h2><a href="http://www.mivascript.com/topic/operators.html">Documentation</a></h2> <h2><a href="http://snippets.miva.com/id/1456864554/latest">snippets.miva.com Examples</a></h2> <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456865827
View "MivaScript Operators"
<h1>MivaScript Operator Examples</h1> <h2><a href="http://www.mivascript.com/topic/operators.html">Documentation</a></h2> <h2><a href="http://snippets.miva.com/id/1456864554/latest">snippets.miva.com Examples</a></h2>c <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456864554
View "MivaScript Operators"
<h1><A href="http://www.mivascript.com/topic/operators.html">MivaScript Operators</A></h1> <mvt:assign name="g.counter" value="1" /> <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

Rounding Sample

 math
Created: 1446766613
View "Rounding Sample"
<mvt:eval expr=".5 ROUND 0" /><br/> <mvt:eval expr="1.5 ROUND 0" /><br/> <mvt:eval expr="rnd(.5, 0)" /><br/> <mvt:eval expr="rnd(1.5, 0)" /><br/>
 

Basket #7407

 math
Created: 1446764890
View "Basket #7407"
<h1>Banker's Rounding</h1> <blockquote> <p>Banker's Rounding is only different from the standard Rounding Up method when the number to be rounded ends in a fraction of 0.5 - <i>If the fraction of y is 0.5, then q is the even integer nearest to y.</i> This method treats positive and negative values symmetrically, and is therefore free of sign bias.</p> </blockquote> <p><a href="http://extranet.miva.com/forums/archive/index.php/t-114506.html">Miva Forum Post</a></p> <hr> <h2>Order #90155 Example</h2> Decimal 2.924 with Banker's Rounding: <mvt:eval expr="rnd(2.924, 2) " /><br> Decimal 2.925 with Banker's Rounding: <mvt:eval expr="rnd(2.925, 2) " /><br> Decimal 2.926 with Banker's Rounding: <mvt:eval expr="rnd(2.926, 2) " /><br> <hr> <h2>Examples -2.0 to 2.0</h2> <table border="1"> <tr> <th>Decimal</th> <th>Rounding Up</th> <th>Banker's Rounding</th> <th>Explanation</th> </tr> <tr> <td>-2.0</td> <td>-2</td> <td><mvt:eval expr="rnd(-2.0, 0)"/></td> <td></td> </tr> <tr> <td>-1.9</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.9, 0)"/></td> <td></td> </tr> <tr> <td>-1.8</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.8, 0)"/></td> <td></td> </tr> <tr> <td>-1.7</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.7, 0)"/></td> <td></td> </tr> <tr> <td>-1.6</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-1.5</h4></td> <td>-1</td> <td><mvt:eval expr="rnd(-1.5, 0)"/></td> <td>Even integers that are closest to -1.5 are 0 & -2.<br>-2 is the closest one, so we round down to -2</td> </tr> <tr> <td>-1.4</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.4, 0)"/></td> <td></td> </tr> <tr> <td>-1.3</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.3, 0)"/></td> <td></td> </tr> <tr> <td>-1.2</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.2, 0)"/></td> <td></td> </tr> <tr> <td>-1.1</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.1, 0)"/></td> <td></td> </tr> <tr> <td>-1.0</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.0, 0)"/></td> <td></td> </tr> <tr> <td>-0.9</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.9, 0)"/></td> <td></td> </tr> <tr> <td>-0.8</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.8, 0)"/></td> <td></td> </tr> <tr> <td>-0.7</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.7, 0)"/></td> <td></td> </tr> <tr> <td>-0.6</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-0.5</h4></td> <td>0</td> <td><mvt:eval expr="rnd(-0.5, 0)"/></td> <td>Even integers that are closest to -0.5 are 0 & -2.<br>0 is the closest one, so we round up to 0</td> </tr> <tr> <td>-0.4</td> <td>0</td> <td><mvt:eval expr="rnd(-0.4, 0)"/></td> <td></td> </tr> <tr> <td>-0.3</td> <td>0</td> <td><mvt:eval expr="rnd(-0.3, 0)"/></td> <td></td> </tr> <tr> <td>-0.2</td> <td>0</td> <td><mvt:eval expr="rnd(-0.2, 0)"/></td> <td></td> </tr> <tr> <td>-0.1</td> <td>0</td> <td><mvt:eval expr="rnd(-0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.0</td> <td>0</td> <td><mvt:eval expr="rnd(0.0, 0)"/></td> <td></td> </tr> <tr> <td>0.1</td> <td>0</td> <td><mvt:eval expr="rnd(0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.2</td> <td>0</td> <td><mvt:eval expr="rnd(0.2, 0)"/></td> <td></td> </tr> <tr> <td>0.3</td> <td>0</td> <td><mvt:eval expr="rnd(0.3, 0)"/></td> <td></td> </tr> <tr> <td>0.4</td> <td>0</td> <td><mvt:eval expr="rnd(0.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>0.5</h4></td> <td>1</td> <td><mvt:eval expr="rnd(0.5, 0)"/> | <mvt:eval expr="0.5 ROUND 0"/></td> <td>Even integers that are closest to 0.5 are 0 & 2.<br>0 is the closest one, so we round down to 0</td> </tr> <tr> <td>0.6</td> <td>1</td> <td><mvt:eval expr="rnd(0.6, 0)"/></td> <td></td> </tr> <tr> <td>0.7</td> <td>1</td> <td><mvt:eval expr="rnd(0.7, 0)"/></td> <td></td> </tr> <tr> <td>0.8</td> <td>1</td> <td><mvt:eval expr="rnd(0.8, 0)"/></td> <td></td> </tr> <tr> <td>0.9</td> <td>1</td> <td><mvt:eval expr="rnd(0.9, 0)"/></td> <td></td> </tr> <tr> <td>1.0</td> <td>1</td> <td><mvt:eval expr="rnd(1.0, 0)"/></td> <td></td> </tr> <tr> <td>1.1</td> <td>1</td> <td><mvt:eval expr="rnd(1.1, 0)"/></td> <td></td> </tr> <tr> <td>1.2</td> <td>1</td> <td><mvt:eval expr="rnd(1.2, 0)"/></td> <td></td> </tr> <tr> <td>1.3</td> <td>1</td> <td><mvt:eval expr="rnd(1.3, 0)"/></td> <td></td> </tr> <tr> <td>1.4</td> <td>1</td> <td><mvt:eval expr="rnd(1.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>1.5</h4></td> <td>2</td> <td><mvt:eval expr="rnd(1.5, 0)"/> | <mvt:eval expr="1.5 ROUND 0"/> </td> <td>Even integers that are closest to 1.5 are 0 & 2.<br>2 is the closest one, so we round up to 2</td> </tr> <tr> <td>1.6</td> <td>2</td> <td><mvt:eval expr="rnd(1.6, 0)"/></td> <td></td> </tr> <tr> <td>1.7</td> <td>2</td> <td><mvt:eval expr="rnd(1.7, 0)"/></td> <td></td> </tr> <tr> <td>1.8</td> <td>2</td> <td><mvt:eval expr="rnd(1.8, 0)"/></td> <td></td> </tr> <tr> <td>1.9</td> <td>2</td> <td><mvt:eval expr="rnd(1.9, 0)"/></td> <td></td> </tr> <tr> <td>2.0</td> <td>2</td> <td><mvt:eval expr="rnd(2.0, 0)"/></td> <td></td> </tr> </table>
 

Banker's Rounding

 math
Created: 1446672284
View "Banker's Rounding"
<h1>Banker's Rounding</h1> <blockquote> <p>Banker's Rounding is only different from the standard Rounding Up method when the number to be rounded ends in a fraction of 0.5 - <i>If the fraction of y is 0.5, then q is the even integer nearest to y.</i> This method treats positive and negative values symmetrically, and is therefore free of sign bias.</p> </blockquote> <p><a href="http://extranet.miva.com/forums/archive/index.php/t-114506.html">Miva Forum Post</a></p> <hr> <h2>Order #90155 Example</h2> Decimal 2.924 with Banker's Rounding: <mvt:eval expr="rnd(2.924, 2) " /><br> Decimal 2.925 with Banker's Rounding: <mvt:eval expr="rnd(2.925, 2) " /><br> Decimal 2.926 with Banker's Rounding: <mvt:eval expr="rnd(2.926, 2) " /><br> <hr> <h2>Examples -2.0 to 2.0</h2> <table border="1"> <tr> <th>Decimal</th> <th>Rounding Up</th> <th>Banker's Rounding</th> <th>Explanation</th> </tr> <tr> <td>-2.0</td> <td>-2</td> <td><mvt:eval expr="rnd(-2.0, 0)"/></td> <td></td> </tr> <tr> <td>-1.9</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.9, 0)"/></td> <td></td> </tr> <tr> <td>-1.8</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.8, 0)"/></td> <td></td> </tr> <tr> <td>-1.7</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.7, 0)"/></td> <td></td> </tr> <tr> <td>-1.6</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-1.5</h4></td> <td>-1</td> <td><mvt:eval expr="rnd(-1.5, 0)"/></td> <td>Even integers that are closest to -1.5 are 0 & -2.<br>-2 is the closest one, so we round down to -2</td> </tr> <tr> <td>-1.4</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.4, 0)"/></td> <td></td> </tr> <tr> <td>-1.3</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.3, 0)"/></td> <td></td> </tr> <tr> <td>-1.2</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.2, 0)"/></td> <td></td> </tr> <tr> <td>-1.1</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.1, 0)"/></td> <td></td> </tr> <tr> <td>-1.0</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.0, 0)"/></td> <td></td> </tr> <tr> <td>-0.9</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.9, 0)"/></td> <td></td> </tr> <tr> <td>-0.8</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.8, 0)"/></td> <td></td> </tr> <tr> <td>-0.7</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.7, 0)"/></td> <td></td> </tr> <tr> <td>-0.6</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-0.5</h4></td> <td>0</td> <td><mvt:eval expr="rnd(-0.5, 0)"/></td> <td>Even integers that are closest to -0.5 are 0 & -2.<br>0 is the closest one, so we round up to 0</td> </tr> <tr> <td>-0.4</td> <td>0</td> <td><mvt:eval expr="rnd(-0.4, 0)"/></td> <td></td> </tr> <tr> <td>-0.3</td> <td>0</td> <td><mvt:eval expr="rnd(-0.3, 0)"/></td> <td></td> </tr> <tr> <td>-0.2</td> <td>0</td> <td><mvt:eval expr="rnd(-0.2, 0)"/></td> <td></td> </tr> <tr> <td>-0.1</td> <td>0</td> <td><mvt:eval expr="rnd(-0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.0</td> <td>0</td> <td><mvt:eval expr="rnd(0.0, 0)"/></td> <td></td> </tr> <tr> <td>0.1</td> <td>0</td> <td><mvt:eval expr="rnd(0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.2</td> <td>0</td> <td><mvt:eval expr="rnd(0.2, 0)"/></td> <td></td> </tr> <tr> <td>0.3</td> <td>0</td> <td><mvt:eval expr="rnd(0.3, 0)"/></td> <td></td> </tr> <tr> <td>0.4</td> <td>0</td> <td><mvt:eval expr="rnd(0.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>0.5</h4></td> <td>1</td> <td><mvt:eval expr="rnd(0.5, 0)"/></td> <td>Even integers that are closest to 0.5 are 0 & 2.<br>0 is the closest one, so we round down to 0</td> </tr> <tr> <td>0.6</td> <td>1</td> <td><mvt:eval expr="rnd(0.6, 0)"/></td> <td></td> </tr> <tr> <td>0.7</td> <td>1</td> <td><mvt:eval expr="rnd(0.7, 0)"/></td> <td></td> </tr> <tr> <td>0.8</td> <td>1</td> <td><mvt:eval expr="rnd(0.8, 0)"/></td> <td></td> </tr> <tr> <td>0.9</td> <td>1</td> <td><mvt:eval expr="rnd(0.9, 0)"/></td> <td></td> </tr> <tr> <td>1.0</td> <td>1</td> <td><mvt:eval expr="rnd(1.0, 0)"/></td> <td></td> </tr> <tr> <td>1.1</td> <td>1</td> <td><mvt:eval expr="rnd(1.1, 0)"/></td> <td></td> </tr> <tr> <td>1.2</td> <td>1</td> <td><mvt:eval expr="rnd(1.2, 0)"/></td> <td></td> </tr> <tr> <td>1.3</td> <td>1</td> <td><mvt:eval expr="rnd(1.3, 0)"/></td> <td></td> </tr> <tr> <td>1.4</td> <td>1</td> <td><mvt:eval expr="rnd(1.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>1.5</h4></td> <td>2</td> <td><mvt:eval expr="rnd(1.5, 0)"/></td> <td>Even integers that are closest to 1.5 are 0 & 2.<br>2 is the closest one, so we round up to 2</td> </tr> <tr> <td>1.6</td> <td>2</td> <td><mvt:eval expr="rnd(1.6, 0)"/></td> <td></td> </tr> <tr> <td>1.7</td> <td>2</td> <td><mvt:eval expr="rnd(1.7, 0)"/></td> <td></td> </tr> <tr> <td>1.8</td> <td>2</td> <td><mvt:eval expr="rnd(1.8, 0)"/></td> <td></td> </tr> <tr> <td>1.9</td> <td>2</td> <td><mvt:eval expr="rnd(1.9, 0)"/></td> <td></td> </tr> <tr> <td>2.0</td> <td>2</td> <td><mvt:eval expr="rnd(2.0, 0)"/></td> <td></td> </tr> </table>
 
View "Banker's Interesting Rounding"
<h1>Banker's Rounding</h1> <blockquote> <p>Banker's Rounding is only different from the standard Rounding Up method when the number to be rounded ends in a fraction of 0.5 - <i>If the fraction of y is 0.5, then q is the even integer nearest to y.</i> This method treats positive and negative values symmetrically, and is therefore free of sign bias.</p> </blockquote> <p><a href="http://extranet.miva.com/forums/archive/index.php/t-114506.html">Miva Forum Post</a></p> <hr> <h2>Order #90155 Example</h2> Decimal 2.924 with Banker's Rounding: <mvt:eval expr="rnd(2.924, 2) " /><br> Decimal 2.925 with Banker's Rounding: <mvt:eval expr="rnd(2.925, 2) " /><br> Decimal 2.926 with Banker's Rounding: <mvt:eval expr="rnd(2.926, 2) " /><br> <hr> <h2>Examples -2.0 to 2.0</h2> <table border="1"> <tr> <th>Decimal</th> <th>Rounding Up</th> <th>Banker's Rounding</th> <th>Explanation</th> </tr> <tr> <td>-2.0</td> <td>-2</td> <td><mvt:eval expr="rnd(-2.0, 0)"/></td> <td></td> </tr> <tr> <td>-1.9</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.9, 0)"/></td> <td></td> </tr> <tr> <td>-1.8</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.8, 0)"/></td> <td></td> </tr> <tr> <td>-1.7</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.7, 0)"/></td> <td></td> </tr> <tr> <td>-1.6</td> <td>-2</td> <td><mvt:eval expr="rnd(-1.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-1.5</h4></td> <td>-1</td> <td><mvt:eval expr="rnd(-1.5, 0)"/></td> <td>Even integers that are closest to -1.5 are 0 & -2.<br>-2 is the closest one, so we round down to -2</td> </tr> <tr> <td>-1.4</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.4, 0)"/></td> <td></td> </tr> <tr> <td>-1.3</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.3, 0)"/></td> <td></td> </tr> <tr> <td>-1.2</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.2, 0)"/></td> <td></td> </tr> <tr> <td>-1.1</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.1, 0)"/></td> <td></td> </tr> <tr> <td>-1.0</td> <td>-1</td> <td><mvt:eval expr="rnd(-1.0, 0)"/></td> <td></td> </tr> <tr> <td>-0.9</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.9, 0)"/></td> <td></td> </tr> <tr> <td>-0.8</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.8, 0)"/></td> <td></td> </tr> <tr> <td>-0.7</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.7, 0)"/></td> <td></td> </tr> <tr> <td>-0.6</td> <td>-1</td> <td><mvt:eval expr="rnd(-0.6, 0)"/></td> <td></td> </tr> <tr> <td><h4>-0.5</h4></td> <td>0</td> <td><mvt:eval expr="rnd(-0.5, 0)"/></td> <td>Even integers that are closest to -0.5 are 0 & -2.<br>0 is the closest one, so we round up to 0</td> </tr> <tr> <td>-0.4</td> <td>0</td> <td><mvt:eval expr="rnd(-0.4, 0)"/></td> <td></td> </tr> <tr> <td>-0.3</td> <td>0</td> <td><mvt:eval expr="rnd(-0.3, 0)"/></td> <td></td> </tr> <tr> <td>-0.2</td> <td>0</td> <td><mvt:eval expr="rnd(-0.2, 0)"/></td> <td></td> </tr> <tr> <td>-0.1</td> <td>0</td> <td><mvt:eval expr="rnd(-0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.0</td> <td>0</td> <td><mvt:eval expr="rnd(0.0, 0)"/></td> <td></td> </tr> <tr> <td>0.1</td> <td>0</td> <td><mvt:eval expr="rnd(0.1, 0)"/></td> <td></td> </tr> <tr> <td>0.2</td> <td>0</td> <td><mvt:eval expr="rnd(0.2, 0)"/></td> <td></td> </tr> <tr> <td>0.3</td> <td>0</td> <td><mvt:eval expr="rnd(0.3, 0)"/></td> <td></td> </tr> <tr> <td>0.4</td> <td>0</td> <td><mvt:eval expr="rnd(0.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>0.5</h4></td> <td>1</td> <td><mvt:eval expr="rnd(0.5, 0)"/></td> <td>Even integers that are closest to 0.5 are 0 & 2.<br>0 is the closest one, so we round down to 0</td> </tr> <tr> <td>0.6</td> <td>1</td> <td><mvt:eval expr="rnd(0.6, 0)"/></td> <td></td> </tr> <tr> <td>0.7</td> <td>1</td> <td><mvt:eval expr="rnd(0.7, 0)"/></td> <td></td> </tr> <tr> <td>0.8</td> <td>1</td> <td><mvt:eval expr="rnd(0.8, 0)"/></td> <td></td> </tr> <tr> <td>0.9</td> <td>1</td> <td><mvt:eval expr="rnd(0.9, 0)"/></td> <td></td> </tr> <tr> <td>1.0</td> <td>1</td> <td><mvt:eval expr="rnd(1.0, 0)"/></td> <td></td> </tr> <tr> <td>1.1</td> <td>1</td> <td><mvt:eval expr="rnd(1.1, 0)"/></td> <td></td> </tr> <tr> <td>1.2</td> <td>1</td> <td><mvt:eval expr="rnd(1.2, 0)"/></td> <td></td> </tr> <tr> <td>1.3</td> <td>1</td> <td><mvt:eval expr="rnd(1.3, 0)"/></td> <td></td> </tr> <tr> <td>1.4</td> <td>1</td> <td><mvt:eval expr="rnd(1.4, 0)"/></td> <td></td> </tr> <tr> <td><h4>1.5</h4></td> <td>2</td> <td><mvt:eval expr="rnd(1.5, 0)"/></td> <td>Even integers that are closest to 1.5 are 0 & 2.<br>2 is the closest one, so we round up to 2</td> </tr> <tr> <td>1.6</td> <td>2</td> <td><mvt:eval expr="rnd(1.6, 0)"/></td> <td></td> </tr> <tr> <td>1.7</td> <td>2</td> <td><mvt:eval expr="rnd(1.7, 0)"/></td> <td></td> </tr> <tr> <td>1.8</td> <td>2</td> <td><mvt:eval expr="rnd(1.8, 0)"/></td> <td></td> </tr> <tr> <td>1.9</td> <td>2</td> <td><mvt:eval expr="rnd(1.9, 0)"/></td> <td></td> </tr> <tr> <td>2.0</td> <td>2</td> <td><mvt:eval expr="rnd(2.0, 0)"/></td> <td></td> </tr> </table>
 

Interesting Rounding

 math
Created: 1446162547
View "Interesting Rounding"
<mvt:eval expr="2.915 " /><br/> <mvt:eval expr="rnd(2.915, 2) " /> <hr/> <mvt:eval expr="2.925 " /><br/> <mvt:eval expr="rnd(2.925, 2) " /> <hr/> <mvt:eval expr="2.935 " /><br/> <mvt:eval expr="rnd(2.935, 2) " /> <hr/> 0.5 = <mvt:eval expr="rnd(0.5, 0)"/><br> 1.5 = <mvt:eval expr="rnd(1.5, 0)"/><br> 2.5 = <mvt:eval expr="rnd(2.5, 0)"/><br> 3.5 = <mvt:eval expr="rnd(3.5, 0)"/><br> 4.5 = <mvt:eval expr="rnd(4.5, 0)"/><br> 5.5 = <mvt:eval expr="rnd(5.5, 0)"/><br> 6.5 = <mvt:eval expr="rnd(6.5, 0)"/><br> 7.5 = <mvt:eval expr="rnd(7.5, 0)"/><br> 8.5 = <mvt:eval expr="rnd(8.5, 0)"/><br> 9.5 = <mvt:eval expr="rnd(9.5, 0)"/><br> 10.5 = <mvt:eval expr="rnd(10.5, 0)"/><br>
 

Interesting Rounding

 math
Created: 1446162435
View "Interesting Rounding"
<mvt:eval expr="2.915 " /><br/> <mvt:eval expr="rnd(2.915, 2) " /> <hr/> <mvt:eval expr="2.925 " /><br/> <mvt:eval expr="rnd(2.925, 2) " /> <hr/> <mvt:eval expr="2.935 " /><br/> <mvt:eval expr="rnd(2.935, 2) " /> <hr/> 0.5 = <mvt:eval expr="rnd(0.5, 0)"/><br> 1.5 = <mvt:eval expr="rnd(1.5, 0)"/><br> 2.5 = <mvt:eval expr="rnd(2.5, 0)"/><br> 3.5 = <mvt:eval expr="rnd(3.5, 0)"/><br>
 

Interesting Rounding

 math
Created: 1446162063
View "Interesting Rounding"
<mvt:eval expr="32.5 * 0.09 " /> <br/> <mvt:eval expr="rnd(32.5 * 0.09, 2) " />
 

Basket #5690

 date  math
Get the formatted date one week from now.
Created: 1441916300
View "Basket #5690"
<mvt:assign name="l.settings:field:value" value="5434123465434536" /> <mvt:assign name="l.settings:field:firstfour" value="substring(l.settings:field:value, 1, 4 )" /> <mvt:assign name="l.settings:field:secondfour" value="substring(l.settings:field:value, 5, 4 )" /> <mvt:assign name="l.settings:field:thirdfour" value="substring(l.settings:field:value, 9, 4 )" /> <mvt:assign name="l.settings:field:lastfour" value="substring(l.settings:field:value, 13, 4 )" /> &mvt:field:firstfour; - &mvt:field:secondfour; - &mvt:field:thirdfour; - &mvt:field:lastfour;
 

Basket #818

 date  math
Get the formatted date one week from now.
Created: 1429208272
View "Basket #818"
<mvt:assign name="l.index" value="miva_array_insert( l.settings:messages, 'hello there 1', -1 )" /> <mvt:assign name="l.index" value="miva_array_insert( l.settings:messages, 'hello someone', -1 )" /> <mvt:assign name="l.index" value="miva_array_insert( l.settings:messages, 'hello someone', -1 )" /> <mvt:assign name="l.settings:index" value="miva_array_insert( l.settings:messages, 'hello someone', -1 )" /> <mvt:assign name="l.settings:messages[5]" value="'surprise'" /> <mvt:assign name="l.settings:messages[1]" value="'surprise'" /> &mvt:index;
 

Formatted Date Math

 date  math
Get the formatted date one week from now.
Created: 1429208230
View "Formatted Date Math"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 7" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> &mvt:global:formatted_future_date;