Icon  

Name of gadget  Calculator 
Section  Logic & Processing 
Number of Tweak pages  1 
Author  LadylexUK, QuietlyWrong 
Last updated  24 Feb 2019 [Beta] 
Description
This gadget allows you to manipulate up to 2 inputs with a mathematical function in order to produce a new number. For example, you can take an input from a randomiser and add 1 to the result , so that the number will be between 1 and 10 rather than 0 and 9. You can also compare two inputs with the calculator, for example sending a positive signal of 1 (true) if input A is greater than input B, and 0 (false) if it is not.
Example Tutorial (adapted from Media Molecule)
 Stamp a light
 Stamp a Value Slider
 Stamp a Calculator
 Connect the Value output on the Value Slider to the A input on the Calculator
 Select the operation to > (greater than)
 Set the B slider on the Calculator to 0.5
 Connect the result output to the power port on the light
 Move the Value slider up and down. Notice the light comes on when the Value Slider shows a value that is greater then 0.5
Tweak Menus

 Operand A
Here you can wire the first number to be manipulated into 1a. or specify a fixed value with the slider. Note that while the slider only allows values to be specified to two decimal places, your inputs (and therefore results) may have more.  Mathematical Function
Choose a mathematical function to operate on A and B, as follows:Top row: Add, Subtract, Multiply, Divide, Greater Than, Equal To
Middle row: Less Than, Remainder, Minimum of, Maximum of, Power of
Bottom row: Round Down, Round to Nearest, Round Up, Absolute ValueSee tips below for more details. Three of these operations, indicated in italics, are comparisons between A and B, so the corresponding Result is not a calculated numeric output but a True (1) or False (0) signal depending on whether the comparison is true (i.e. A > B, A = B, A < B).
 Operand B
Here you can wire the second number in your mathematical formula into 3a. or specify a fixed value with the slider. This option is deactivated for the last four mathematical functions, i.e. rounding and taking the absolute value.  Result
This produces a continuous signal of the result of the mathematical function.  Power
This is where you turn the gadget on/off
Lex Tips
In order to calculate >= or <= you will need two Calculators (one calculating the more than or less than comparison, and one calculating the equal to) and an OR gate. Unless of course they add the option in a later version of the calc.
(QW: an alternative is to rephrase the operation: asking whether A >= B is the same as asking whether A is NOT < B. You could therefore use a calculator with a NOT gate, though be wary: if one of your inputs, A or B, is not a valid numeric value, the calculator will return false, in which case you’ll get a misleading true value from the subsequent NOT gate.)
QW Tips
At present, the number of operators on the calculator may seem limited, but a number of mathematical functions can be achieved in multiple ways, so sometimes it is a matter of rephrasing the mathematical question. For example, there is no square root option, but you can obtain the square root of any positive number by raising it to the power of ½ (0.5). This is not always perfect (most calculators wouldn’t cope with obtaining the cube root of a negative number this way, for example) but is good in most scenarios.
If you can’t find what you need – such as trigonometric functions, pi, etc – it’s simple to search the Dreamiverse for “math” gadgets that other DreamShapers have constructed from combinations of calculators or the regular sine wave signal of the wave generator.
For reference purposes, in case any of the operators is unclear to you, here is what each one does:
 Add, Subtract, Multiply and Divide should be obvious (A + B, A – B, A × B, A ÷ B)
 Greater Than – returns true if A > B (false otherwise)
 Equal To – returns true if A = B (false otherwise)
 Less Than – returns true if A < B (false otherwise)
 Remainder – returns the remainder when A is divided by B, for example when 8 is divided by 3, the remainder is 2.
 Minimum of – returns whichever is the smaller of the two inputs, A or B
 Maximum of – returns whichever is the larger of the two inputs, A or B
 Power of – returns the result of the operation A raised to the power B (A^{B})
 Round Down – returns the value of A, rounded down to the nearest integer
 Round to Nearest – returns the value of A, rounded to the nearest integer
 Round Up – returns the value of A, rounded up to the nearest integer
 Absolute Value – also called Magnitude – returns the value of A as a positive number, regardless of whether the input is postive or negative. So inputs of either 5 or 5 will both produce a result of 5.
Comments and Feedback