Skip to content

ozgunlu/nano-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

nano-base

PyPI License Size CI

Tiny base converter (2..36) β€” ~1 KB, zero deps. 255 β†’ FF (base 10β†’16), FF β†’ 11111111 (16β†’2), negatives supported. Perfect for code-golf, minimal containers, or just for fun.


✨ Features

  • βœ… Convert between any bases 2..36 (digits 0-9A-Z, case-insensitive)
  • βœ… Two forms:
    • <value> <to_base> (assumes from=10)
    • <value> <from_base> <to_base>
  • βœ… Handles negatives, 0

πŸš€ Usage

# Local (from repo)
python app_min.py 255 16        # FF
python app_min.py FF 16 2       # 11111111
python app_min.py -42 10 16     # -2A

After installing:

# CLI
pip install nano-base
nano-base 255 16                # -> FF
nano-base FF 16 2               # -> 11111111
nano-base -2A 16 10             # -> -42

πŸ€“ Why so small?

  • Uses int(s, base) + tiny loop to format in target base
  • No bigint libs; Python int already arbitrary precision
  • Single tiny file + tiny CLI: perfect for scripts, containers, CI.

πŸŽ‰ Fun Ideas

  • Hex table (0..255)
for i in $(seq 0 255); do printf "%3d -> %s\n" $i "$(nano-base $i 16)"; done
  • Binary width (pad with printf)
printf "%08d\n" "$(nano-base 42 2)"   # 000101010 (pad separately)
  • Base36 IDs
nano-base 123456789 10 36   # -> 21I3V9

Note: Valid range is bases 2..36; input is case-insensitive (a..z ≑ A..Z).


πŸ“œ License

MIT Β© 2025

About

Tiny base converter (2..36) in ~1KB of Python. Zero dependencies. Golf-friendly πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages