(Redirected from () plus () (block))
- "Add" redirects here. For the List block with "Add" in its name, see Add () to () (block).
|() + ()|
The numbers can be typed directly into the block, or Reporter blocks can be used instead.
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
set [n v] to (0) repeat (length of [numbers v]) change [n v] by (1) set [sum v] to ((item (n) of [numbers v]) + (sum)) end
- Math formulas
((((2) * (pi)) * ((r) * (r))) + (((2) * (pi)) * ((r) * (h))))
when green flag clicked ask [what is the sum] and wait forever if <(answer) = [1+1]> then say ((1) + (1)) end
|This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.|
Sometimes in Scratch 1.4 and previous versions, very large numbers are converted 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