Revision as of 14:37, 2 August 2012 by Scimonster (talk | contribs) (It's nice to have pages on obsolete blocks.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

abs ()
Abs ().png
Category Numbers
Type Reporter
Introduced in 1.0
Removed in 1.2

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

The absolute value is the distance 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|.

Workaround

This block could be replicated with the following code:

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

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.

See Also

() of ()