# To BCD

Binary-Coded Decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign. To BCD lives in the **Data format** category of the `fx` menu.

## Parameters

| Parameter     | Type    | Required | Default   | Description                                                                                        |
| ------------- | ------- | -------- | --------- | -------------------------------------------------------------------------------------------------- |
| Input         | string  | yes      | —         | Value to transform. Previous step output or a literal.                                             |
| Scheme        | string  | no       | `8 4 2 1` | Choose one of: `8 4 2 1`, `7 4 2 1`, `4 2 2 1`, `2 4 2 1`, `8 4 -2 -1`, `Excess-3`, `IBM 8 4 2 1`. |
| Packed        | boolean | no       | `true`    | Enabled by default.                                                                                |
| Signed        | boolean | no       | `false`   | Disabled by default.                                                                               |
| Output format | string  | no       | `Nibbles` | Choose one of: `Nibbles`, `Bytes`, `Raw`.                                                          |

`Input` is the primary value (previous step output or a literal).

## Returned value

| Type     | Description                          |
| -------- | ------------------------------------ |
| `string` | Result of the To BCD transformation. |

## Limitations

- Invalid or mismatched encoding for the chosen options typically raises an evaluation error — fix the Input or options before re-running.

## Example

<details>
<summary>Run To BCD</summary>

Binary-Coded Decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Adjust optional parameters when the defaults do not match your payload.

1. Set **Input** to the value to transform (previous step output or a literal).

2. Review **Scheme**, **Packed**, **Signed**, **Output format** and keep defaults unless your format requires otherwise.

3. Confirm **Output value** shows the transformed result.

</details>
