binToDec() function

Reads a string of '0' and '1' as an unsigned bigint.

Signature:

export declare function binToDec(binStr: string): bigint;

Parameters

Parameter

Type

Description

binStr

string

big-endian binary digits, most significant first

Returns:

bigint

The value they encode. An empty string gives 0n.

Remarks

Only '1' contributes: any other character at a position — including '0', a space or a letter — is treated as a zero bit rather than rejected. So this silently accepts input it cannot represent, and is meant for strings this package produced.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.