Logic Gadgets: Calculator


Name of gadget Calculator
Section Logic & Processing
Number of Tweak pages 1
Author LadylexUK, QuietlyWrong
Last updated 24 Feb 2019 [Beta]


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)

  1. Stamp a light
  2. Stamp a Value Slider
  3. Stamp a Calculator
  4. Connect the Value output on the Value Slider to the A input on the Calculator
  5. Select the operation to > (greater than)
  6. Set the B slider on the Calculator to 0.5
  7. Connect the result output to the power port on the light
  8. 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

  1. Operand A
    1a. Input
    2b. Output
  2. Mathematical function
  3. Operand B
    3a. Input
    3b. Output
  4. Result
    4b. Input
  5. Power
  1. 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.
  2. 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 Value

    See 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).

  3. 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.
  4. Result
    This produces a continuous signal of the result of the mathematical function.
  5. 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 (AB)
  • 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.


Useful Tutorials

Beginner’s guide to the Calculator

Comments and Feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: