(Workaround)
m (top: template removal and cleanup)
 
(8 intermediate revisions by 5 users not shown)
Line 20: Line 20:
 
This block could be replicated with the following code:
 
This block could be replicated with the following code:
 
<scratchblocks>
 
<scratchblocks>
if <(num) < (0)>
+
if <(num) < (0)> then
 
set [abs v] to ((num) * (-1))
 
set [abs v] to ((num) * (-1))
 
else
 
else
Line 27: Line 27:
 
</scratchblocks>
 
</scratchblocks>
  
Or:
+
The new block
  
 
<scratchblocks>
 
<scratchblocks>
[abs v] of ()
+
([abs v] of (9))
 
</scratchblocks>
 
</scratchblocks>
  
Line 38: Line 38:
 
{{Operators Blocks}}{{Removed Blocks}}
 
{{Operators Blocks}}{{Removed Blocks}}
 
[[Category:Operators Blocks]]
 
[[Category:Operators Blocks]]
 +
[[ja:() の絶対値 (ブロック)]]

Latest revision as of 03:12, 17 February 2018

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. For information on the feature that replaced this one, see () of () (Operators block).
abs ()
Abs ().png
Category Numbers
Type Reporter
Introduced in 1.0
Removed in 1.2

The abs () block was a Numbers block and a Reporter block. The block reports the absolute value of the argument.

The absolute value is the distance of a number from 0. Another way to describe absolute value is that it makes a number positive—if it is negative, it becomes positive, and if it is positive, it stays positive. For example, the absolute value of -3 is +3 and the absolute value of +4 is +4. The mathematical way to write absolute value is |number|. For example, abs(-3) is the same as |-3|.

Removal

In Scratch 1.2, this block was removed, and replaced with a general () of () block. It contains 12 mathematical functions. The top value is abs, but the default is sqrt (square root).

Its position in the palette was between () mod () and round (). The new block is at the bottom of the palette.

Workaround

This block could be replicated with the following code:

if <(num) < (0)> then
set [abs v] to ((num) * (-1))
else
set [abs v] to (num)
end

The new block

([abs v] of (9))

See Also