Linux command
bcal 命令
趣味
复制后可按需替换文件名、目录或参数。
常用示例
Evaluate an arithmetic expression
bcal "(5kb+2mb)/3"
Convert a value
bcal 0xaabbcc kb
Show binary, decimal and hex
bcal -c 20140115
Perform bitwise operations
bcal -b '0xFF & 0x0F'
Use as a general-purpose calculator
bcal -b '3.5 * 2.1 + 5.7'
Convert LBA to CHS
bcal -f l500
Convert CHS to LBA
bcal -f c10-10-10
Start interactive REPL mode
bcal
说明
bcal (Byte CALculator) is a command-line utility for calculations and expressions involving binary prefixes, SI/IEC conversion, byte addressing, base conversion, and LBA/CHS calculation. It also supports general-purpose arithmetic, bitwise operations, and mathematical functions. Storage expressions support the operators +, -, \*, /, % with units such as B, KiB, MiB, GiB, TiB, kB, MB, GB, and TB. Units are case-insensitive. Hex values are prefixed with 0x and binary values with 0b. In general-purpose mode (-b), bcal supports bitwise operations: AND (&), OR (|), XOR (^), complement (~), left shift (<<), and right shift (>>). Mathematical functions include exp(n), log(base, n), ln(n), pow(n, exponent), and root(radical, n). When started without arguments, bcal enters an interactive REPL mode. The last valid result is stored in the variable r and can be reused in subsequent expressions. In the REPL, press b to toggle between storage and general-purpose modes, c N for base conversion, p N for bit positions, s for storage type sizes, and q or double Enter to quit. bcal works with piped input and file redirection, making it suitable for scripted workflows. Precision is 128-bit when __uint128_t is available, otherwise 64-bit. Floating-point operations use long double arithmetic.
参数
- -b _expr_
- Start general-purpose REPL mode. If an expression is provided, evaluate it and quit.
- -c _N_
- Show decimal, binary and hex representation of positive integer N.
- -p _N_
- Show bit positions and bit values of a number.
- -f _loc_
- Convert CHS to LBA or LBA to CHS. The location is a hyphen-separated representation.
- -s _bytes_
- Sector size in bytes. Default value is 512.
- -m
- Show minimal output (e.g. decimal bytes only).
- -d
- Enable debug information and logs.
- -h
- Show help, storage sizes on the system, and exit.
FAQ
What is the bcal command used for?
bcal (Byte CALculator) is a command-line utility for calculations and expressions involving binary prefixes, SI/IEC conversion, byte addressing, base conversion, and LBA/CHS calculation. It also supports general-purpose arithmetic, bitwise operations, and mathematical functions. Storage expressions support the operators +, -, \*, /, % with units such as B, KiB, MiB, GiB, TiB, kB, MB, GB, and TB. Units are case-insensitive. Hex values are prefixed with 0x and binary values with 0b. In general-purpose mode (-b), bcal supports bitwise operations: AND (&), OR (|), XOR (^), complement (~), left shift (<<), and right shift (>>). Mathematical functions include exp(n), log(base, n), ln(n), pow(n, exponent), and root(radical, n). When started without arguments, bcal enters an interactive REPL mode. The last valid result is stored in the variable r and can be reused in subsequent expressions. In the REPL, press b to toggle between storage and general-purpose modes, c N for base conversion, p N for bit positions, s for storage type sizes, and q or double Enter to quit. bcal works with piped input and file redirection, making it suitable for scripted workflows. Precision is 128-bit when __uint128_t is available, otherwise 64-bit. Floating-point operations use long double arithmetic.
How do I run a basic bcal example?
Run `bcal "(5kb+2mb)/3"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -b _expr_ do in bcal?
Start general-purpose REPL mode. If an expression is provided, evaluate it and quit.