> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bash Numeric Base Literal

A Bash numeric base literal is a syntactic construct used within arithmetic evaluation contexts to define an integer in an arbitrary radix (base) ranging from 2 to 64.

## Syntax

The primary syntax for defining a base literal utilizes the hash (`#`) delimiter:

```bash theme={"dark"}
base#number
```

* **`base`**: A decimal integer between `2` and `64` specifying the radix.
* **`number`**: The sequence of characters representing the integer value in the specified radix.

If the `base#` prefix is omitted entirely, Bash evaluates the number as a standard base 10 integer (unless a C-style prefix is present). The `#` delimiter is strictly a separator and cannot be used without a preceding `base`.

## Lexical Representation and Character Mapping

To represent digit values greater than 9, Bash employs a specific character mapping sequence:

* **Values 0–9**: Digits `0` through `9`.
* **Values 10–35**: Lowercase letters `a` through `z`.
* **Values 36–61**: Uppercase letters `A` through `Z`.
* **Value 62**: The at-symbol `@`.
* **Value 63**: The underscore `_`.

*Note:* If the specified `base` is less than or equal to 36, Bash treats lowercase and uppercase letters interchangeably for values 10 through 35.

## C-Style Base Prefixes

In addition to the `base#number` format, Bash supports standard C-style prefixes for octal and hexadecimal literals:

* **Octal (Base 8)**: A leading `0` (zero) followed by octal digits.
* **Hexadecimal (Base 16)**: A leading `0x` or `0X` followed by hexadecimal digits.

## Arithmetic Evaluation Contexts

Bash evaluates numeric base literals in *all* arithmetic evaluation contexts. These contexts include:

* Arithmetic expansions (`$(( ... ))`)
* Arithmetic compound commands (`(( ... ))`)
* The `let` builtin command
* Array subscripts (`array[index]`)
* Parameter substring expansion offsets and lengths (`${parameter:offset:length}`)
* Integer-attributed variable assignments (variables declared with `declare -i`)
* Conditional command arithmetic operators (e.g., `-eq`, `-lt`) evaluated strictly within the `[[ ... ]]` keyword.

*Note:* The `[` (`test`) builtin command is **not** an arithmetic evaluation context. It relies on standard C-library string-to-integer conversion. Using a Bash base literal inside `[` (e.g., `[ 16#FF -eq 255 ]`) will result in an `integer expression expected` error.

## Syntax Visualization

```bash theme={"dark"}

# Arithmetic expansions and compounds
$(( 2#1010 ))              # Binary: Evaluates to 10
$(( 8#17 ))                # Octal: Evaluates to 15
$(( 017 ))                 # Octal (C-style): Evaluates to 15
$(( 16#FF ))               # Hexadecimal: Evaluates to 255
$(( 16#ff ))               # Hexadecimal: Evaluates to 255 (Case-insensitive <= base 36)
$(( 0xFF ))                # Hexadecimal (C-style): Evaluates to 255
$(( 64#1_ ))               # Base 64: Evaluates to 127 (1 * 64^1 + 63 * 64^0)
$(( 64#@0 ))               # Base 64: Evaluates to 3968 (62 * 64^1 + 0 * 64^0)


# Array subscripts
arr[16#FF]="value"         # Evaluates index as 255


# Substring expansion
${var:16#A:2#10}           # Evaluates offset as 10, length as 2


# Integer-attributed variables
declare -i num=16#FF       # Evaluates literal and assigns 255 to num


# Conditional arithmetic operators (Must use [[ ]], not [ ])
[[ 16#FF -eq 255 ]]        # Evaluates to true (0 exit status)
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Bash Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
