BinaryFormat.Decimal

Binary

A binary format that reads a .NET 16-byte decimal value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

BinaryFormat.Decimal(binary as binary) as any

Parameters

NameTypeRequiredDescription
binarybinaryYesThe binary data to read the 16-byte decimal value from.

Return Value

functionA binary format function that reads a 16-byte .NET decimal value from binary data.

Remarks

BinaryFormat.Decimal is a binary format specifier that reads a .NET 16-byte decimal value from binary data. The .NET decimal type uses 128 bits (16 bytes) and can represent values with up to 28-29 significant digits without rounding errors, making it suitable for financial and monetary calculations.

The 16 bytes are laid out in .NET decimal format: the first 12 bytes hold the 96-bit integer mantissa, and the last 4 bytes contain the sign bit and scaling factor (number of decimal places).

Use this format within BinaryFormat.Record or other composite formats when parsing binary files that contain .NET-serialized decimal values.

Examples

Example 1: Read a decimal value from binary data

let
    // .NET decimal representation of 1.0:
    // 96-bit integer = 10, scale factor = 1, sign = positive
    binaryData = #binary({
        0x0A, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x01, 0x00
    }),
    result = BinaryFormat.Decimal(binaryData)
in
    result

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks