{
  "category": "Engineering functions",
  "display_name": "HEX2OCT",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.HEX2OCT",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 1218,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 1218,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 1,218 in the answer bank and 4 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 1,222 recorded answers",
    "workbook_corpus": {
      "cells": 4,
      "matched": 4
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/engineering.rs#L158-L158",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/engineering_radix_family.rs#L192-L194"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/engineering::radix_kind",
        "catalogue/engineering::places",
        "catalogue/engineering::between",
        "ported/base_fn::int_to_base",
        "ported/base_fn::base_kernel",
        "ported/engineering_radix_family::upper_ascii_digit_value",
        "ported/engineering_radix_family::normalize_radix_text",
        "ported/engineering_radix_family::parse_radix_text",
        "ported/engineering_radix_family::normalize_places",
        "ported/engineering_radix_family::min_signed_value",
        "ported/engineering_radix_family::max_signed_value",
        "ported/engineering_radix_family::encode_signed_value",
        "ported/engineering_radix_family::source_to_target_kernel"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/engineering.rs#L158-L158",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 1,222 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.HEX2OCT.json",
  "name": "HEX2OCT",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[OCT2HEX](FUNC.OCT2HEX.md) converts in the reverse direction. [BASE](FUNC.BASE.md) and [DECIMAL](FUNC.DECIMAL.md) provide general radix conversion with different sign rules. A full-width negative engineering encoding is not a minus-prefixed numeral; choose the pair whose sign convention fits your input.\n\n\n",
    "how-to-implement": "\nSeparate input parsing, signed interpretation and output formatting. Uppercase the source, validate its digit set and length, and accumulate `raw=raw*16+digit` with checked integer arithmetic. Only a full ten-digit source with its top bit set is negative: subtract `2^40` to obtain signed integer `v`. Check `v` against the 30-bit signed target range. If negative, encode `2^30+v` in base 8 using ten digits. Otherwise use repeated division by 8, reverse the remainders and left-pad to the requested width. Truncate the width and validate it in the current supported range one through ten. Return text; a decimal number formatted to look similar is a different value kind.\n\n\n",
    "quirks": "\nThese engineering conversions use signed fixed-width encodings, not arbitrary-length integers. The source accepts at most ten digits; a full ten-digit encoding uses 40-bit two’s complement. `FFFFFFFFFF` represents minus one. Invalid source digits or an oversized input give `#NUM!`. For a positive result a width too small gives `#NUM!`. A negative result uses ten digits; the current code still validates an explicitly supplied width before emitting it, despite documentation describing the width as ignored.\n\n\n",
    "sources": "\n- [Microsoft: HEX2OCT function](https://support.microsoft.com/en-us/excel/functions/hex2oct-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/ported/engineering_radix_family.rs); implementation steps and the limits identified in the text.\n\n",
    "try-it": "\n`=HEX2OCT(\"2D\",4)` returns `\"0055\"`. All of these represent the same integer: decimal 45, binary `101101`, octal `55`, and hexadecimal `2D`.\n\nFor a negative value, `=HEX2OCT(\"FFFFFFFFD3\",4)` returns `\"7777777723\"`. Decode `1099511627731-2^40=-45`, then encode `2^30-45` in ten octal digits. Check the 30-bit destination range before formatting.\n\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20430 | Windows, 64-bit, CPU not recorded | 1,218 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.HEX2OCT.json).",
    "what-it-does": "\n`HEX2OCT(number, [places])` converts hexadecimal to octal. The result is text, with optional leading zeros controlled by `places`.\n\n\n"
  },
  "signature": {
    "display": "HEX2OCT(number, [places])",
    "parameters": [
      {
        "description": null,
        "name": "number",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "places",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 1
      },
      "category": "Engineering functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Hexadecimal number written in octal",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Converts a hexadecimal number to octal",
        "microsoft_url": "https://support.microsoft.com/en-us/office/hex2oct-function-54d52808-5d19-4bd0-8a63-1096a5d11912"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "HEX2OCT"
        },
        {
          "locale": "bg-BG",
          "name": "HEX2OCT"
        },
        {
          "locale": "cs-CZ",
          "name": "HEX2OCT"
        },
        {
          "locale": "da-DK",
          "name": "HEX.TIL.OKT"
        },
        {
          "locale": "de-DE",
          "name": "HEX2OCT"
        },
        {
          "locale": "el-GR",
          "name": "HEX2OCT"
        },
        {
          "locale": "en-AU",
          "name": "HEX2OCT"
        },
        {
          "locale": "en-GB",
          "name": "HEX2OCT"
        },
        {
          "locale": "en-US",
          "name": "HEX2OCT"
        },
        {
          "locale": "es-ES",
          "name": "HEX.A.OCT"
        },
        {
          "locale": "et-EE",
          "name": "HEX2OCT"
        },
        {
          "locale": "fi-FI",
          "name": "HEKSAOKT"
        },
        {
          "locale": "fr-FR",
          "name": "HEXOCT*"
        },
        {
          "locale": "he-IL",
          "name": "HEX2OCT"
        },
        {
          "locale": "hr-HR",
          "name": "HEX2OCT"
        },
        {
          "locale": "hu-HU",
          "name": "HEX.OKT"
        },
        {
          "locale": "id-ID",
          "name": "HEX2OCT"
        },
        {
          "locale": "it-IT",
          "name": "HEX2OCT"
        },
        {
          "locale": "ja-JP",
          "name": "HEX2OCT"
        },
        {
          "locale": "ko-KR",
          "name": "HEX2OCT"
        },
        {
          "locale": "lt-LT",
          "name": "HEX2OCT"
        },
        {
          "locale": "lv-LV",
          "name": "HEX2OCT"
        },
        {
          "locale": "nb-NO",
          "name": "HEKSTILOKT"
        },
        {
          "locale": "nl-NL",
          "name": "HEX.N.OCT"
        },
        {
          "locale": "pl-PL",
          "name": "SZESN.NA.ÓSM"
        },
        {
          "locale": "pt-BR",
          "name": "HEX2OCT"
        },
        {
          "locale": "pt-PT",
          "name": "HEXAOCT"
        },
        {
          "locale": "ro-RO",
          "name": "HEX2OCT"
        },
        {
          "locale": "ru-RU",
          "name": "ШЕСТН.В.ВОСЬМ"
        },
        {
          "locale": "sk-SK",
          "name": "HEX2OCT"
        },
        {
          "locale": "sl-SI",
          "name": "HEX2OCT"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "HEX2OCT"
        },
        {
          "locale": "sv-SE",
          "name": "HEX.TILL.OKT"
        },
        {
          "locale": "th-TH",
          "name": "HEX2OCT"
        },
        {
          "locale": "tr-TR",
          "name": "HEX2OCT işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "HEX2OCT"
        },
        {
          "locale": "vi-VN",
          "name": "HEX2OCT"
        },
        {
          "locale": "zh-CN",
          "name": "HEX2OCT"
        },
        {
          "locale": "zh-HK",
          "name": "HEX2OCT"
        },
        {
          "locale": "zh-TW",
          "name": "HEX2OCT"
        }
      ],
      "signature": {
        "display": "HEX2OCT(number, [places])",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "places",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "HEX2OCT",
      "version_marker": null,
      "xlcall": {
        "code": "386",
        "symbol": "xlfHex2oct"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/hex2oct-function-54d52808-5d19-4bd0-8a63-1096a5d11912"
  },
  "try_it": {
    "formula": "=HEX2OCT(\"2D\",4)"
  },
  "url": "https://handbook.dnacalc.com/functions/HEX2OCT.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "1,218 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.HEX2OCT.json"
      ]
    }
  ]
}