Math Modules

Basic math functions. Except where noted, all math functions operate on double precision floating point, so decimal fractions as well as very large numbers are supported.


Unity Add Addx Sub Mul Div IDiv IMod IDivMod Percent Scale Offset

Round Int Even Fract Abs Negate Sign

Bound Range Expand


Unity

Simply passes the input to the output. Unlike other Math modules, Unity can handle text as well as numeric values. The module is useful for feeding a single value into several module inputs simultaniously.

Output:

Out: Unaltered copy of the input.

Input:

In: Any numeric or text value.


Add

Add two inputs.

Output:

Out: Sum of the two inputs.

Input:

In 1: Any numeric value.

In 2: Any numeric value.


Addx

Add multiple value inputs, returns sum. Works with a user settable number of inputs ("x" stands for eXpandable). To change the number of inputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Inputs tab. You have the option to set custom input labels and tool tips if you like.

Output:

Out: Sum of all the inputs.

Inputs:

In N: Any numeric value.


Sub

Subtract -Input from Input

Output:

Out: Result of subtraction.

Input:

In: Any numeric value.

-In: Any numeric value.


Mul

Multiply two inputs.

Output:

Out: Product of multiplying the two inputs.

Input:

In 1: Any numeric value.

In 2: Any numeric value.


Div

Divide top In value by /In.

Caution: Division by 0 (0 in the /In input) produces an error. While it does no harm other than to flag the error and report it in the status line, the error processing does take substantial extra CPU cycles, so you should not leave this input at 0.

Output:

Out: Divide result.

Input:

In: Any numeric value.

/In: Any non zero numeric value.


IDiv

Integer division of top In value by /In. Returns the truncated divide result as integer.

Returns 0 on divide by 0, does not flag an error.

Output:

Out: Divide result.

Input:

In: Any numeric value.

/In: Any non zero numeric value.


IMod

Integer division of top In value by /In. Returns the the modulus (remainder) value as an integer.

The modulus result is particularly useful in creating a numeric range value, because it causes the value to fold over like the milage numbers on an odemeter. For example if you want to limit a value from 0 to 99, put 100 into the /In input, and the result is guaranteed to be within 0 to 99.

Returns 0 on divide by 0, does not flag an error.

Output:

Out: Modulus (remainder).

Input:

In: Any numeric value.

/In: Any non zero numeric value.


IDivMod

Integer division of top In value by /In. Returns the truncated divide result plus the modulus (remainder) value, both as integers.

The modulus result is particularly useful in creating a numeric range value, because it causes the value to fold over like the milage numbers on an odemeter. For example if you want to limit a value from 0 to 99, put 100 into the /In input, and the result is guaranteed to be within 0 to 99.

Returns 0 on divide by 0, does not flag an error.

Output:

Div: Divide result.

Mod: Modulus (remainder).

Input:

In: Any numeric value.

/In: Any non zero numeric value.


Percent

Retern percent of a value.

Output:

Out: Percent of In by %In.

Input:

In: Any numeric value.

%In: Any numeric value, as percent operator.


Scale

Scale a value from original range to scale range.

Output:

Out: Scaled value, with offset added.

Input:

In: Any numeric value to be scaled.

From: The range of the original, input value. Assumes a range of 0 to the value given.

To: The range to scale to. Assumes a range of 0 to the value given.

Round: Round to given decimal places (0-22).

Ofst: Value to add to the scaled value. Added after rounding.


Offset

Adds a single offset to any number of input values. Works with a user settable number of input/output pairs. To change the number of input/output pairs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Inputs/Outputs tab. You have the option to set custom input labels and tool tips if you like.

Output:

Val N : Sum of the corresponding Val N input plus the Ofst input.

Input:

Val N: Any numeric value.

Ofst: Any numeric value, to be added to the Val N inputs.


Round

Round to given decimal places (0-22). Note that for maximum efficiency this value is not error checked; it will throw "Error in Main Loop" and slow down ArtWonk if given values outside the legal range.

Output:

Out: Rounded value from input.

Input:

In: Any numeric value.

Places: Number of places after decimal to round, 0 for integer.


Int

Truncate the decimal fraction part of a value, returning only the integer part.

Output:

Out: Truncated integer of input.

Input:

In: Any numeric value.


Even

Converts input to an even integer. The method used is to add .5, convert to an integer, then AND with -2.

Output:

Out: Input to nearest even integer.

Input:

In: Any numeric value.


Fract

Returns fractional part of the input.

Output:

Out: Fractional part of input.

Input:

In: Any numeric value.


Abs

Absolute forces input to a positive value.

Output:

Out: Absolute of input.

Input:

In: Any numeric value.


Negate

Negate (make negative, change sign of) a value.

Output:

Out: Value to be negated.

Input:

In: Negative of input.


Sign

Test input value for sign and <0.

Output:

Sgn: Returns 1 if positive, 0 if 0, -1 if negative.

<0: Returns 1 if negative, 0 if positive or 0.

Input:

In: Any numeric value to be tested.


Bound

Bound a value between Max and Min.

Output:

Out: Input bounded between Min and Max.

Input:

In: Any numeric value to be bounded.

Max: Max value, upper bound of input.

Min: Min value, lower bound of input.


Range

Test In input to determine if it is within range given by Max and Min. If within range, send to Val output, and set Test output to True (1); if not within range, hold Val output at last value that was within range, and set Test output to False(0).

Output:

Val: Copy of last input value within range.

Test: True (1) if input value is within range.

Input:

In: Any numeric value to be ranged.

Max: Max value, upper range of input.

Min: Min value, lower range of input.


Expand

Expand or contract a value; bound output to within Min and Max.

Output:

Out: Expansion or contraction of In input.

Input:

In: Value to be expanded or contracted.

Max: Max value, upper bound of output.

Min: Min value, lower bound of output.

Expan: Absolute multiplier to expand In input if > 1; contract if < 1.

Round: Round to given decimal places (0-22). Note that for maximum efficiency this value is not error checked; it will throw "Error in Main Loop" and slow down ArtWonk if given values outside the legal range.

 

ArtWonk is Copyright © 2003-2014 by John Dunn and Algorithmic Arts. All Rights Reserved