| THE META-HTML LANGUAGE REFERENCE MANUAL

Flow Control | [TOC] | Relational Operators

## Section Intro: Arithmetic Operators

Synopsis:

Meta-HTML contains a small set of commands for operating on numerical quantities.

All of the arithmetic operators described in this section can accept a number, or simply the name of a variable, which is then looked up as if it had been written with `<get-var ...>`.

That is to say:

       <set-var total = <add <get-var subtotals[0]>
                             <get-var subtotals[current]>>>

can be written as:

       <set-var total = <add subtotals[0] subtotals[current]>>

Commands:

add decrement div | increment mod | mul random | randomize sub

Variables:

mhtml::decimal-places |  |  |

More Information:

The binary arithmetic operators always expect two arguments, and will produce a warning message in `DEBUGGING-OUTPUT` when given too few arguments.

You can perform floating point arithmetic if one or both of the arguments is already a floating point number:

      <div 10 3>    --> 3
      <div 10.0 3>  --> 3.33

### Function Documentation

`<add ARG1 ARG2>` | Simple

Returns the sum of ARG1 and ARG2.

`<decrement VARNAME [BY=AMOUNT]>` | Simple

Subtract AMOUNT (default 1) from the contents of the variable named by VARNAME.

       <set-var foo=1>
       <get-var foo> --> 1
       <decrement foo>
       <get-var foo> --> 0

Also see `increment`.

`<div ARG1 ARG2>` | Simple

Returns the quotient of ARG1 and ARG2.

        <div 12 2> --> 6
        <div 10 3> --> 3

`<increment VARNAME [BY=AMOUNT]>` | Simple

Add AMOUNT (default 1) to the contents of the variable named by VARNAME.

       <set-var foo=1>
       <get-var foo> --> 1
       <increment foo>
       <get-var foo> --> 2

Also see `decrement`.

`<mod ARG1 ARG2>` | Simple

Returns the remainder of ARG1 and ARG2.

        <mod 12 2> --> 0
        <mod 10 3> --> 1

`<mul ARG1 ARG2>` | Simple

Returns the product of ARG1 and ARG2.

        <mul 12 2> --> 24

`<random [ARG]>` | Simple

Returns a pseudo-random number between 0 and ARG -1. The distribution is pretty good; calling `<random 2>` returns 0 50% of the time, and 1 the other 50%.

Also see `randomize`.

`<randomize [ARG]>` | Simple

Sets the pseudo-random number generator seed to ARG. The next call to `random` uses this seed value to find the next pseudo-random number. There is no return value.

        <randomize 10>
        <random 100> --> 28
        <random 100> --> 15
        <randomize 10>
        <random 100> --> 28

`<sub ARG1 ARG2>` | Simple

Returns the difference of ARG1 and ARG2.

        <sub 12 2> --> 10

Edit Section
Function Index
Variable Index

The META-HTML Reference Manual V1.4 Copyright © 1995, 1996, Brian J. Fox, 1996, 1997 Universal Access Inc.
Found a bug? Send mail to bug-manual@metahtml.com