Skip to content

kszongic/bcd-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@kszongic/bcd-cli

npm version license

Encode and decode Binary Coded Decimal (BCD) from the command line. Zero dependencies.

Install

npm install -g @kszongic/bcd-cli

Usage

# Encode decimal to BCD
bcd encode 1234
# BCD binary: 0001 0010 0011 0100
# BCD hex:    0x1234
# BCD bytes:  12 34

bcd encode 9876
# BCD binary: 1001 1000 0111 0110
# BCD hex:    0x9876
# BCD bytes:  98 76

# Decode BCD hex to decimal
bcd decode 0x1234
# 1234

bcd decode 98 76
# 9876

# Pipe from stdin
echo "42" | bcd encode

# Shorthand: just pass a number
bcd 42

What is BCD?

Binary Coded Decimal encodes each decimal digit in 4 bits (a nibble). It's widely used in financial systems, embedded devices, and legacy protocols where exact decimal representation matters.

Digit BCD
0 0000
1 0001
2 0010
... ...
9 1001

License

MIT © 2026 kszongic

Releases

No releases published

Packages

 
 
 

Contributors