(Redirected from () minus () (block))

() - () | |

Category |
Operators |

Type |
Reporter |

The **() - ()** block is an Operators block and a Reporter block. The block subtracts the second value from the first and reports the result.

The numbers can be typed directly into the block, or Reporter blocks can be used instead.

This block can be stacked inside itself; this can be used to fit more numbers in.

## Example Uses

In many projects, numbers must be subtracted; this block will do the job.

Some common uses for the () - () block:

- Scripts in calculator simulations

ask [What is your first number?] and wait set [First Number v] to (answer) ask [What do you want to subtract from that?] and wait say (join [The answer is: ] ((First Number) - (answer)))

- Creating a compact button

when gf clicked set [Song on? v] to (1) when this sprite clicked set [Song on? v] to ((3) - (Song on?)) if <(Song on?) = (1)> then play sound [This is a party! v] else stop all sounds end

- Math formulas

ask [You want to find the distance from Sprite1 to Sprite2, correct?] and wait set [Distance Apart v] to ([sqrt v] of (((([x position v] of [Sprite1 v]) - ([x position v] of [Sprite2 v])) * (([x position v] of [Sprite1 v]) - ([x position v] of [Sprite2 v]))) + ((([y position v] of [Sprite1 v]) - ([y position v] of [Sprite2 v])) * (([y position v] of [Sprite1 v]) - ([y position v] of [Sprite2 v]))))) say (join [The distance from Sprite1 to Sprite2 is: ](Distance Apart))

## Scientific Notation

In Scratch 1.4 and previous versions, it sometimes converts very large numbers into scientific notation to save space. Scientific notation is simply the number in the form A*10^{B}, displayed as AeB. These can be converted to a normal number by performing any mathematical function on it, such as adding. So if a variable named "number" has a value of 3*10^{3} and one wants to display it as a normal number, you can change it by:

((number) + (0))

It will then report "3000".

## Workaround

*Main article: List of Block Workarounds*

The block can be replicated with both of the following:

((a) + ((b) * (-1)))

((a) + (join [-] (b)))

a is the starting number, b is the number to be subtracted, and the resulting number is the result of the subtraction.

## See Also

() + ()
• () - () • () * () • () / () • Pick Random () to () • () < () • () = () • () > () • () and () • () or () • Not () • Join ()() • Letter () of () • Length of () • () Mod () • Round () • () of ()More blocks... |