jarun/bcal is a developer-focused project on GitHub with 707 stars, written primarily in C. :1234: Bits, bytes and general-purpose calculator
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
bcal (Byte CALculator) is a REPL CLI utility for storage expression (e.g. "(2GiB * 2) / (2KiB >> 2)") evaluation, SI/IEC conversion, byte address calculation, base conversion and LBA/CHS calculation. It's very useful for those who deal with bits, bytes, addresses and binary prefixes frequently.
To evaluate general-purpose operations, use bcal -b or prompt key b.
bcal uses SI and IEC binary prefixes and supports 64-bit Operating Systems only.
Table of Contents
Features
Installation
Dependencies
From a package manager
From source
make options
Termux
Usage
cmdline options
Operational notes
Environment variables
Examples
Testing
Copyright
Features
REPL and single execution modes
evaluate arithmetic expressions involving storage units
REPL 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
Installation
Dependencies
bcal is written in C and depends on standard libc and GNU Readline (or BSD Editline). However, readline can be excluded by building with O_NORL=1, which uses a native input prompt with history file support instead.
From a package manager
Install bcal from your package manager. If the version available is dated try an alternative installation method.
Packaging status (expand)
From source
If you have git installed, clone this repository. Otherwise, download the latest stable release or development version (risky).
Install to default location (/usr/local):
$ sudo make strip install
To link to libedit:
$ sudo make O_EL=1 strip install
To build without readline dependency (uses native input with history file support):
$ sudo make O_NORL=1 strip install
To uninstall, run:
$ sudo make uninstall
PREFIX is supported, in case you want to install to a different location.
make options
O_NORL=1: build without GNU Readline (native prompt with history file support).
O_EL=1: link against BSD Editline instead of Readline.
O_STATIC=1: build a static binary (forces O_NORL=1).
strip: target to strip the resulting binary after build.
static: target to build a static binary via O_STATIC=1.
To build with musl libc, use musl-gcc as the compiler, for example:
$ CC=musl-gcc make
$ CC=musl-gcc make O_STATIC=1
Termux
bcal can be compiled and installed from source in the Termux environment on aarch64 Android devices. Instructions:
$ wget https://github.com/jarun/bcal/archive/master.zip
$ unzip bcal-master.zip
$ cd bcal-master/
$ pkg install make clang readline-dev
$ make strip install
Usage
cmdline options
usage: bcal [-b [expr]] [-c N] [-p N] [-f loc]
[-s bytes] [expr] [N [unit]] [-m] [-H] [-d] [-h]
Bits, bytes and general-purpose calculator.
positional arguments:
expr expression in decimal/hex operands
N [unit] capacity in B/KiB/MiB/GiB/TiB/kB/MB/GB/TB
https://en.wikipedia.org/wiki/Binary_prefix
default unit is B (byte), case is ignored
N can be decimal or '0x' prefixed hex value
optional arguments:
-b [expr] start in general-purpose REPL mode
or, evaluate expression and quit
-c N show +ve integer N in binary, decimal, hex
-p N show bit position with bit value for N
-f loc convert CHS to LBA or LBA to CHS
refer to the operational notes in man page
-s bytes sector size [default 512]
-m show minimal output (e.g. decimal bytes)
-H show integral maths results in hex
-d enable debug information and logs
-h show this help
prompt keys:
b toggle general-purpose mode
c N show +ve integer N in binary, decimal, hex
p N show bit position with bit value for N
r show result from last operation
s show sizes of storage types
? show prompt help
q/double ↵ quit program
prompt: bytes> for storage mode, maths> for general-purpose mode
Operational notes
REPL 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 single execution mode must be quoted. Inner spaces are ignored. Operators supported in storage expressions: +, -, *, /, %.
N [unit]: N can be a decimal or '0x' prefixed hex value. unit can be B/KiB/MiB/GiB/TiB/kB/MB/GB/TB. Default is Byte. As all of these tokens are unique, unit is case-insensitive. Note that bcal doesn't support bit as a unit.
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 with 0b.
Precision: 128 bits if __uint128_t is available or 64 bits for numeric conversions. Floating point operations use long 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.
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
Default values:
sector size: 0x200 (512)
max heads per cylinder: 0x10 (16)
max sectors per track: 0x3f (63)
REPL mode: r is synced and can be used in expressions. The built-in evaluator uses long double arithmetic.
History file: Stored at $XDG_CONFIG_HOME/bcal/history, or $HOME/.config/bcal/history if XDG_CONFIG_HOME is unset.
Environment variables
BCAL_BIT_ANSI_COLOR_CODE: ANSI escape code to colorize bit value 1 in -p output. Set to empty to disable coloring. Examples:
export BCAL_BIT_ANSI_COLOR_CODE=$'\033[1;92m' // ANSI 8-bit color code
export BCAL_BIT_ANSI_COLOR_CODE=$'\u001b[1;38;5;51m' // ANSI 256-bit color code
export BCAL_BIT_ANSI_COLOR_CODE='' // Disable coloring
Due to the nature of the project, it's extremely important to test existing functionality before raising any PR. bcal has several test cases written in test.py. To execute the test cases locally, install pytest and run:
No homepage URL was recorded for jarun/bcal in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on jarun/bcal?
The most recent commit recorded on jarun/bcal was 18 days ago, based on the GitHub push timestamp. The repository has 40 forks — one of the better signals of community interest.
How many stars does jarun/bcal have?
jarun/bcal has 707 GitHub stars — refresh the page for the live number, or check github.com/jarun/bcal. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is jarun/bcal written in?
jarun/bcal is written primarily in C. GitHub's language field is based on the largest share of bytes in the default branch.
What license does jarun/bcal use?
jarun/bcal is released under the GPL-3.0 license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/jarun/bcal is the definitive source.
Read full README in the tab above.
Want a second opinion on bcal?
Ask an AI that can read this page — one click and you get its take on bcal.