p5.js compact reference
v2.3.2

abs()

method

Math / Calculation

Signature

abs(n: Number): Number

Description

Calculates the absolute value of a number. A number's absolute value is its distance from zero on the number line. -5 and 5 are both five units away from zero, so calling abs(-5) and abs(5) both return 5. The absolute value of a number is always positive.

Parameters

  • n : Number
    number to compute.

Returns

Number
absolute value of given number.

src/math/calculation.js:36