p2 is a tiny Go CLI for printing powers of 2 through 2^32.
p2prints the default list from2^0to2^16p2 5prints2^5 = 32p2 0..8prints exponents0through8p2 1-16does the same with a shorter range aliasp2 30000finds the closest supported power of 2 and prints2^15 = 32,768p2 30,000works too- Exact midpoint ties return both matches on separate lines, for example
p2 48prints2^5 = 32and2^6 = 64 - By default, single-result lookups also copy the raw numeric value to your clipboard
- Optional user config controls list bounds, comma formatting, and clipboard copy for single-result lookups
p2 --configwalks you through a simple interactive setupp2 --resetrestores a clean default config file
Install into ~/.local/bin:
./install.shThis install path builds p2 from source, so it requires Go to be installed locally.
Install into a custom location:
BINDIR="$HOME/bin" ./install.shBuild manually:
go build ./cmd/p2p2
p2 5
p2 0..8
p2 1-16
p2 30000
p2 48
p2 --help
p2 --config
p2 --resetp2 reads an optional user config file from your platform config directory:
- macOS:
~/Library/Application Support/p2/config.json - Linux:
~/.config/p2/config.json - Windows:
%AppData%\p2\config.json
Example:
{
"lower_bound": 5,
"upper_bound": 8,
"use_commas": true,
"copy_single_to_clipboard": true
}Notes:
lower_boundandupper_boundaffect barep2only- explicit ranges like
p2 0..32andp2 16-5ignore config bounds - descending ranges normalize to ascending output
- ranges are exponent-only input; nearest-by-value lookup remains single-number-only
- comma-separated lists such as
p2 0,1,5,32are not supported - fresh installs default to
upper_bound: 16, even when no config file exists yet use_commaschanges display formatting onlycopy_single_to_clipboarddefaults totrue- single-result lookups copy the raw numeric value without commas
- the config file is created when you run
p2 --configorp2 --reset
go test ./...
go build ./cmd/p2This project is licensed under the MIT License.