Drop #665 (2025-06-16): According To My Calculations…

calc; bcal; pdd

We’ve got three highly useful CLI tools that handle different types of calculations with ease. At a minimum, I’m hoping everyone at least makes the resources in the first or second sections part of your standard toolbox.


TL;DR

(This is an LLM/GPT-generated summary of today’s Drop using Ollama + Qwen 3 and a custom prompt.)

  • calc is a C-style arbitrary precision calculator that uses exact rational arithmetic for precise mathematical computations (https://github.com/lcn2/calc)
  • bcal is a command-line utility that simplifies digital storage calculations by handling SI and IEC units, conversions, and storage formats (https://github.com/jarun/bcal)
  • pdd is a minimalist date and time calculator that supports ISO 8601, natural date formats, countdowns, and stopwatches (https://github.com/jarun/pdd)

calc: Precision Matters

Photo by KATRIN BOLOVTSOVA on Pexels.com

calc is a C-style arbitrary precision calculator excels at precise mathematical computation. Every number is internally represented as a fraction and automatically reduced to lowest terms. This means you’re working with exact rational arithmetic, not floating-point approximations that accumulate errors.

The tool uses a C-like syntax that feels immediately familiar to coders. You can define functions, use control structures, assign variables, and build complex mathematical scripts. It’s the rare utility that scales gracefully from quick mental math (3 * (4 + 1)) to serious computational exploration.

Complex numbers receive the royal treatment. Operations such as (2+3i) * (4-3i) produce exact results rather than decimal approximations. The calculator supports multiple number bases and output formats, accepting input in binary, octal, decimal, or hexadecimal while displaying results in whatever format serves your purpose.

“But, hrbrmstr, we have bc!”

Yes, but while bc offers POSIX compliance and portability for basic decimal calculations, calc provides true arbitrary precision, exact rational arithmetic, and sophisticated mathematical capabilities. If you’re working with very large numbers, need complex number support, or want precise symbolic results rather than floating-point approximations, calc represents the more mathematically rigorous choice.

We’re also covering calc due to the mid-section resource.


bcal: Byte Me

Photo by Anete Lusina on Pexels.com

Working with digital storage calculations shouldn’t require a computer science degree, yet here we are in 2025 still often wrestling with the eternal question: is that kilobyte really 1,000 or 1,024 bytes? Enter bcal (Byte CALculator), a command-line utility that cuts through the confusion with surgical precision. Built by prolific CLI tool-writer Arun Prakash Jana, this utility solves a specific problem — juggling bits, bytes, and storage calculations — exceptionally well.

The tool operates in two modes: interactive REPL for exploratory calculations and one-shot command-line execution for scripting. Want to calculate (2GiB * 2) / (2KiB >> 2)? Just type it! bcal understands both SI units (kB, MB) and IEC binary prefixes (KiB, MiB), converting between them seamlessly.

For true storage nerds, it can convert between byte addresses, LBA (Logical Block Addressing), and CHS (Cylinder-Head-Sector) formats with customizable sector sizes. Base conversions between binary, decimal, and hexadecimal happen effortlessly. When you need calculations beyond storage units, bcal gracefully hands off to either bc or the more feature-rich and aforementioned calc utility (set export BCAL_USE_CALC=1 for calc support).

Usage feels intuitive once you understand the syntax. Storage calculations look like natural expressions: bcal "5 tb / 12" or bcal "2.5mb*3". Unit conversions happen with simple arguments: bcal 0x1335053 B converts that hex value to various byte representations. The LBA/CHS conversion feature (bcal -f l500 or bcal -f c10-10-10) addresses specialized storage administration needs that few tools even acknowledge.

It uses up to 128-bit integers when supported, falling back to 64-bit otherwise, with long double precision for floating-point operations. Results floor to integer bytes because fractional bytes don’t exist in computing reality. The tool accepts piped input and file operations, making it genuinely scriptable rather than just interactive.

Longtime readers know I’m partial to “one thing well” tools, and bcal 100% fits in that category. If you do poke at it a bit, I’m fairly convinced it’ll find a place in your shell’s muscle memory.


pdd: No More Bad Dates

Photo by Quintin Gellar on Pexels.com

I wasn’t kidding in the mid-section when I said Arun Prakash Jana is a prolific CLI writer. They also wrote pdd (Python3 Date Diff) — a minimalist command-line utility that may actually make the mundane task of date calculations into something almost approaching fun.

While it first-and-foremost calculates differences between dates and times, it has other features such as countdown timers, stopwatches, and general date arithmetic. As ome might expect, pdd supports ISO 8601 standards, but can deal with almost any “natural” date format, and also handles partial inputs pretty gracefully. Want to know how many days until your project deadline? Simply run pdd 2025 Dec 15. Need to add three months to a date? The syntax is fairly intuitive: pdd -d 2025 Jan 15 0 3 0 --add. No memorizing arcane flags or wrestling with formatting quirks.

Running pdd -c 00:05:00 -r 'notify-send "Break time over"' creates a five-minute countdown that executes a command when complete. This is perfect for you Pomodoro cult members. The stopwatch feature, with configurable millisecond precision, turns your terminal into a timing instrument.

We seem to living through an interesting moment in software development where the pendulum swings back toward focused, dependency-light tools. pdd represents this trend perfectly. It’s stable, maintained, actively developed, and solves real problems without requiring you to learn yet another complex framework.

Now, if only someone would port this to a real programming language.


FIN

Remember, you can follow and interact with the full text of The Daily Drop’s free posts on:

  • 🐘 Mastodon via @dailydrop.hrbrmstr.dev@dailydrop.hrbrmstr.dev
  • 🦋 Bluesky via https://bsky.app/profile/dailydrop.hrbrmstr.dev.web.brid.gy

☮️

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.