BCAL(1)
π BCAL(1) β the manual, but make it cute π
okay bestie, sit down, hydrate, and let me tell you about bcal(1) β it's the storage expression calculator and it's genuinely iconic. π«Ά
β¨ NAME β¨
bcal β Storage expression calculator. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
bcal [-b [expr]] [-c N] [-p N] [-f loc] [-s bytes] [expr] [N [unit]]
[-m] [-d] [-h]
π¦ DESCRIPTION π¦
so like, bcal (which stands for Byte CALculator, adorable) is a command-line utility that helps you with numerical calculations and expressions involving binary prefixes, SI/IEC conversion, byte addressing, base conversion, LBA/CHS calculation, etc. like. all of it. π
it comes with a built-in expression mode (-b) for general-purpose numerical calculations, so it's giving calculator energy too. β¨
and bcal uses the [SI and IEC binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) β that's the link, i'm not making it up: https://en.wikipedia.org/wiki/Binary_prefix
π FEATURES π
the way that this little program does SO much, i'm obsessed:
- evaluate arithmetic expressions involving storage units π
- perform general purpose calculations (built-in expression mode)
- arithmetic: addition, subtraction, multiplication, division, modulo
- bitwise: AND (
&), OR (|), XOR (^), complement (~), lshift (<<), rshift (>>) - functions:
exp(n),log(base, n),ln(n)[natural log],pow(n, exponent),root(radical, n)
- works with piped input or file redirection π
- convert to IEC/SI standard data storage units
- interactive mode with the last valid result stored for reuse π₯
- show the address in bytes
- show address as LBA:OFFSET
- convert CHS to LBA and vice versa
- base conversion to binary, decimal and hex
- show bit positions with bit value of a number
- custom sector size, max heads/cylinder and max sectors/track
- minimal dependencies (low maintenance queen π§)
π OPERATIONAL NOTES π
read these, bestie, they matter. no cap.
- Interactive mode: bcal enters the REPL mode if no arguments are provided. Storage unit conversion, base conversion and expression evaluation are supported in this mode. The last valid result is stored in the variable
r. π - Expression: Expression passed as argument in one-shot mode must be within double quotes. Inner spaces are ignored. Supported operators:
+,-,*,/,%and C bitwise operators (except~due to storage width dependency). - N [unit]: N can be a decimal or
0xprefixed hex value. unit can beB/KiB/MiB/GiB/TiB/kB/MB/GB/TB. Default is Byte. As all of these tokens are unique, unit is case-insensitive. π¦ - Numeric representation: Decimal and hex are recognized in expressions and unit conversions. Binary is also recognized in other operations.
- Syntax: Prefix hex inputs with
0x, binary inputs with0b. (iykyk π ) - Precision: 128 bits if
__uint128_tis available or 64 bits for numerical conversions. Floating point operations uselong double. Negative values in storage expressions are unsupported. Only 64-bit operating systems are supported. - Fractional bytes do not exist, because they can't be addressed. bcal shows the floor value of non-integer bytes. π (imagine a half byte. you can't.)
- CHS and LBA syntax:
- LBA:
'lLBA-MAX_HEAD-MAX_SECTOR'[NOTE: LBA starts with'l'(case ignored)] - CHS:
'cC-H-S-MAX_HEAD-MAX_SECTOR'[NOTE: CHS starts with'c'(case ignored)] - Format conversion arguments must be hyphen separated.
- Any unspecified value, including the one preceding the first
'-'to the one following the last'-', is considered'0'(zero). - Examples:
'c-50--0x12-'-> C = 0, H = 50, S = 0, MH = 0x12, MS = 0'l50-0x12'-> LBA = 50, MH = 0x12, MS = 0
- LBA:
- Default values:
- sector size:
0x200(512) - max heads per cylinder:
0x10(16) - max sectors per track:
0x3f(63)
- sector size:
- Expression mode:
ris synced and can be used in expressions. The built-in evaluator useslong doublearithmetic. β
π OPTIONS π
one bullet per flag because we respect the source material in this house:
-b=[expr]β Start in numeric expression mode. If expression is provided, evaluate and quit. β¨-c=Nβ Show decimal, binary and hex representation of positive integer N. π-p=Nβ Show bit position (reversed if set) and bit value of a number. π-f=locβ Convert CHS to LBA or LBA to CHS.locis hyphen-separated representation of LBA or CHS. Please refer to the Operational Notes section for more details. π-s=bytesβ Sector size in bytes. Default value is512.-mβ Show minimal output (e.g. decimal bytes). minimal queen π§-dβ Enable debug information and logs. π (for the nosy ones, love that for you)-hβ Show program help, storage sizes on the system and exit. π«Ά
π PROMPT KEYS π
the interactive mode keys, memorise them bestie:
bβ Toggle numeric expression mode.rβ Show result from last operation.sβ Show sizes of storage types.?β Show prompt help.q, double Enter β Quit the program. bye bye π
π₯ EXAMPLES π₯
1. Evaluate arithmetic expression of storage units
$ bcal "(5kb+2mb)/3"
$ bcal "5 tb / 12"
$ bcal "2.5mb*3"
$ bcal "(2giB * 2) / (2kib >> 2)"
2. Convert storage capacity to other units and get address, LBA.
$ bcal 20140115 b
$ bcal 0x1335053 B
$ bcal 0xaabbcc kb
$ bcal 0xdef Gib
Note that the units are case-insensitive. π
3. Convert storage capacity, set sector size to 4096 to calculate LBA.
$ bcal 0xaabbcc kb -s 4096
4. Convert LBA to CHS.
$ bcal -f l500
$ bcal -f l0x600-18-0x7e
$ bcal -f l0x300-0x12-0x7e
5. Convert CHS to LBA.
$ bcal -f c10-10-10
$ bcal -f c0x10-0x10-0x10
$ bcal -f c0x10-10-2-0x12
$ bcal -f c-10-2-0x12
$ bcal -f c0x10-10--0x12
6. Show binary, decimal and hex representations of a number.
$ bcal -c 20140115
$ bcal -c 0b1001100110101000001010011
$ bcal -c 0x1335053
bcal> c 20140115 // Interactive mode
7. Perform bitwise operations.
$ bcal -b '0xFF & 0x0F'
$ bcal -b '0x0F | 0xF0'
$ bcal -b '0xFF ^ 0xF0'
$ bcal -b '~0xF0'
$ bcal -b '0x01 << 3'
$ bcal -b '0x10 >> 2'
$ bcal -b '(0xFF & 0x0F) | (0x0F << 4)'
8. Use expression mode.
$ bcal -b '3.5 * 2.1 + 5.7'
bcal> b // Interactive mode
expr> 3.5 * 2.1 + 5.7
9. Pipe input.
$ printf '15 kib + 15 gib \n r / 5' | bcal -m
$ printf '15 + 15 + 2' | bcal -bm
10. Redirect from file.
$ cat expr
15 gib + 15 kib
r / 5
$ bcal -m < expr
11. Use as a general-purpose calculator.
$ bcal -b
12. Use mathematical functions.
$ bcal -b 'root(2, 17.3)' // square root on 17.3
$ bcal -b 'exp(5.2)'
$ bcal -b 'pow(2, 8)'
$ bcal -b 'pow(10, 3) + root(2, 9)'
π«Ά AUTHORS π«Ά
Arun Prakash Jana <engineerarun@gmail.com> β the icon, the moment, the blueprint π
π HOME π
π REPORTING BUGS π
https://github.com/jarun/bcal/issues
π LICENSE π
Copyright Β© 2016 Arun Prakash Jana <engineerarun@gmail.com>
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
no warranty bestie, it's giving "use at your own risk" but make it legal π
and that's the whole page!! Version 2.5, dated 20 Feb 2026 β go forth and calculate, you absolute storage genius πβ¨π
π¦ where this page comes from
- fedora 43: bcal 2.5-1.fc43 Β· GPL-3.0-or-later
- fedora 44: bcal 2.5-1.fc44 Β· GPL-3.0-or-later
- nixos 26.05: bcal 2.5
- ubuntu stonking: bcal 2.5-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms