From Test-Scratch-Wiki

"Add" redirects here. For the List block with "Add" in its name, see Add () to () (block).
() + ()
2.0 () + ().png
Category Operators
Type Reporter

The () + () block is an Operators block and a Reporter block. The block adds two values and reports the result.

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

Example Uses

In many projects, numbers must be added together —this block will do the job.

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

  • Calculator scripts
set [answer v] to ((a) + (b))
  • Adding lists of numbers
repeat (length of [numbers v])
change [n v] by (1)
set [sum v] to ((item (n) of [numbers v]) + (sum))
  • Math formulas
((((2) * (pi)) * ((r) * (r))) + (((2) * (pi)) * ((r) * (h))))
  • Addition
when green flag clicked
ask [what is the sum] and wait
if <(answer) = [1+1]> then 
say ((1) + (1))

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*10b. 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*103 and one want to display it as a normal number, one can change it by:

((number) + (0))

It will then report "3000".


Main article: List of Block Workarounds

The block can be replicated with the following code:

((a) - ((0) - (b)))
((a) - ((-1) * (b)))
set [output v] to (a) 
change [output v] by (b) //output would be the answer, 'a' would be the first number, 'b' the second

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.