{
  "id": "multiplication",
  "version": "161529ffb80f",
  "status": "published",
  "name": "Multiplication Calculator",
  "question": "How do I do long multiplication?",
  "summary": "Multiplies two numbers exactly, whole numbers or decimals of any length, and shows the long multiplication: each partial product, their sum, and the decimal point.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/multiplication-calculator",
  "markdown": "https://www.acalculator.org/math/multiplication-calculator.md",
  "kind": "function",
  "method": "Multiply without the decimal points: one partial product per non-zero digit of the second number (the first number times that digit and its place value), then add them; the product has as many decimal places as both numbers together.",
  "assumptions": [
    "Each number is read exactly as typed, with any number of digits; the product is exact.",
    "A digit 0 in the second number gives no partial product.",
    "The product is negative when exactly one number is negative."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "First number",
        "description": "The number to multiply, such as 123, -4.5 or 1,234.56.",
        "type": "string",
        "maxLength": 40
      },
      "b": {
        "title": "Second number",
        "description": "The number to multiply by; the working takes one partial product per digit of it.",
        "type": "string",
        "maxLength": 40
      }
    }
  },
  "outputs": {
    "product": {
      "label": "Product",
      "description": "The exact product of the two numbers.",
      "format": "text"
    },
    "steps": {
      "label": "Long multiplication",
      "description": "The partial products, their sum, the decimal point, and the sign.",
      "format": "text"
    },
    "problem": {
      "label": "Problem",
      "description": "The two numbers with the × sign, written out in full.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": "123",
      "b": "45"
    },
    "outputs": {
      "product": "5535",
      "steps": "123 × 5 = 615; 123 × 40 = 4920; Add the partial products: 615 + 4920 = 5535",
      "problem": "123 × 45"
    },
    "text": "123 × 45 = 5535."
  },
  "examples": [
    {
      "given": {
        "a": "123",
        "b": "45"
      },
      "expect": {
        "product": "5535",
        "steps": "123 × 5 = 615; 123 × 40 = 4920; Add the partial products: 615 + 4920 = 5535"
      },
      "source": "hand calculation in content.mdx; Python 3: 123 * 45 = 5535; method from OpenStax Prealgebra 2e, section 1.4: https://openstax.org/books/prealgebra-2e/pages/1-4-multiply-whole-numbers"
    },
    {
      "given": {
        "a": "12.3",
        "b": "4.5"
      },
      "expect": {
        "product": "55.35",
        "steps": "Set the decimal points aside: 123 × 45; 123 × 5 = 615; 123 × 40 = 4920; Add the partial products: 615 + 4920 = 5535; 1 + 1 = 2 decimal places: 55.35"
      },
      "source": "hand calculation in content.mdx; Python 3: Decimal(\"12.3\") * Decimal(\"4.5\") = 55.35"
    },
    {
      "given": {
        "a": "-2.5",
        "b": "0.4"
      },
      "expect": {
        "product": "-1",
        "steps": "Set the decimal points aside: 25 × 4; 25 × 4 = 100; 1 + 1 = 2 decimal places: 1.00; One number is negative, so the product is negative: -1"
      },
      "source": "hand calculation in content.mdx; Python 3: Decimal(\"-2.5\") * Decimal(\"0.4\") = -1.00"
    },
    {
      "given": {
        "a": "987654321",
        "b": "123456789"
      },
      "expect": {
        "product": "121932631112635269"
      },
      "source": "Python 3: 987654321 * 123456789 = 121932631112635269 (exact integers)"
    },
    {
      "given": {
        "a": "2,048",
        "b": "305"
      },
      "expect": {
        "product": "624640",
        "steps": "2048 × 5 = 10240; 2048 × 300 = 614400; Add the partial products: 10240 + 614400 = 624640"
      },
      "source": "hand calculation in content.mdx: the 0 in 305 gives no partial product; Python 3: 2048 * 305 = 624640"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, section 1.4 Multiply Whole Numbers (multi-digit multiplication): https://openstax.org/books/prealgebra-2e/pages/1-4-multiply-whole-numbers",
    "OpenStax, Prealgebra 2e, section 5.2 Decimal Operations (multiplying decimals): https://openstax.org/books/prealgebra-2e/pages/5-2-decimal-operations"
  ],
  "related": [
    "decimal",
    "division",
    "exponent",
    "order-of-operations"
  ],
  "changelog": []
}
