{
  "id": "absolute-value",
  "version": "199d03659ee9",
  "status": "published",
  "name": "Absolute Value Calculator",
  "question": "What is the absolute value?",
  "summary": "Computes the absolute value |x| of a number or fraction, the distance |a − b| between two numbers, or solves the absolute value equation |mx + n| = c, exactly.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/absolute-value-calculator",
  "markdown": "https://www.acalculator.org/math/absolute-value-calculator.md",
  "kind": "function",
  "method": "|x| = x if x ≥ 0, −x if x < 0; distance = |a − b|; |mx + n| = c gives x = (c − n) ÷ m or x = (−c − n) ÷ m.",
  "assumptions": [
    "Inputs are exact: whole numbers, decimals, fractions such as 3/4, or mixed numbers such as 1 1/2.",
    "Answers are exact fractions in lowest terms."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "mode": {
        "title": "Find",
        "description": "What to work out: the absolute value of one number, the distance between two, or an equation.",
        "type": "string",
        "enum": [
          "value",
          "distance",
          "equation"
        ]
      },
      "x": {
        "title": "Number x",
        "description": "The number to take the absolute value of: a whole number, decimal or fraction.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "a": {
        "title": "Number a",
        "description": "The first number.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "b": {
        "title": "Number b",
        "description": "The second number.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "m": {
        "title": "m",
        "description": "The number that multiplies x inside the bars.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "n": {
        "title": "n",
        "description": "The number added to m·x inside the bars.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "c": {
        "title": "c",
        "description": "The number on the right of the equals sign.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Answer",
      "description": "The absolute value, the distance, or the solutions for x, as exact fractions (a mixed number above 1).",
      "format": "text"
    },
    "decimal": {
      "label": "As a decimal",
      "description": "The absolute value or the distance as a decimal.",
      "format": "number"
    },
    "statement": {
      "label": "Working",
      "description": "The answer written out, for example |−7| = 7 or x = 2 or x = −1.",
      "format": "text"
    },
    "count": {
      "label": "Number of solutions",
      "description": "How many values of x solve the equation: 0, 1, 2, or every number.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "mode": "value",
      "x": "-7",
      "a": "3",
      "b": "10",
      "m": "2",
      "n": "-1",
      "c": "3"
    },
    "outputs": {
      "result": "7",
      "decimal": 7,
      "statement": "|-7| = 7"
    },
    "text": "|-7| = 7."
  },
  "examples": [
    {
      "given": {
        "mode": "value",
        "x": "-7"
      },
      "expect": {
        "result": "7",
        "decimal": 7,
        "statement": "|-7| = 7"
      },
      "source": "OpenStax Algebra and Trigonometry 2e, section 2.6, Other Types of Equations: if x < 0, |x| = −x (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-6-other-types-of-equations, retrieved 2026-10-01)"
    },
    {
      "given": {
        "mode": "value",
        "x": "-3/4"
      },
      "expect": {
        "result": "3/4",
        "decimal": 0.75
      },
      "source": "OpenStax Algebra and Trigonometry 2e, section 2.6 (definition of absolute value); hand calculation in content.mdx"
    },
    {
      "given": {
        "mode": "distance",
        "a": "3",
        "b": "10"
      },
      "expect": {
        "result": "7",
        "statement": "|3 − 10| = 7"
      },
      "source": "OpenStax Algebra and Trigonometry 2e, section 2.6 (absolute value as distance); hand calculation in content.mdx"
    },
    {
      "given": {
        "mode": "equation",
        "m": "2",
        "n": "-1",
        "c": "3"
      },
      "expect": {
        "statement": "x = -1 or x = 2",
        "count": "2"
      },
      "source": "OpenStax Algebra and Trigonometry 2e, section 2.6, Other Types of Equations: |2x − 1| = 3 gives x = 2 and x = −1 (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-6-other-types-of-equations)"
    },
    {
      "given": {
        "mode": "equation",
        "m": "3",
        "n": "6",
        "c": "0"
      },
      "expect": {
        "result": "-2",
        "count": "1"
      },
      "source": "OpenStax Algebra and Trigonometry 2e, section 2.6: if c = 0, |ax + b| = c has one solution; hand calculation in content.mdx"
    }
  ],
  "sources": [
    "OpenStax, Algebra and Trigonometry 2e, section 2.6, Other Types of Equations (definition of absolute value; |ax + b| = c has no solution for c < 0, one for c = 0, two for c > 0; example |2x − 1| = 3), CC BY 4.0, retrieved 2026-10-01. https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-6-other-types-of-equations"
  ],
  "related": [
    "fraction",
    "equation-solver"
  ],
  "changelog": []
}
