Absolute Value Calculator Formula
Understand the math behind the absolute value calculator. Each variable explained with a worked example.
Formulas Used
Abs Val
abs_val = abs(num)Sign
sign = num > 0 ? 1 : (num < 0 ? -1 : 0)Squared
squared = pow(num, 2)Variables
| Variable | Description | Default |
|---|---|---|
num | Number | -7.5 |
How It Works
Absolute Value
Definition
|x| = x if x ≥ 0, and |x| = -x if x < 0
The absolute value of a number is its distance from zero on the number line, always non-negative.
Properties
Worked Example
Find the absolute value of -7.5.
num = -7.5
- 01|-7.5| = 7.5
- 02The number is negative, so the sign is -1
- 03(-7.5)² = 56.25
Ready to run the numbers?
Open Absolute Value Calculator