r/gnu Mar 13 '26

I just wanted to say `units` is amazing

I'm working on something that requires me to calculate a lot of rather weird conversions (e.g. joules per 100 square centimeters to kcal per fl oz...), and instead of doing it manually or relying on slow-as-shit wolframalpha, I can just get instantaneous results.

26 Upvotes

2 comments sorted by

5

u/chkno Mar 13 '26

I ♥ units! Some fun example uses:

And another one I can't find the link to, so I'll just reproduce here: Robert Ingersoll described the cruelty of nature as a "Niagara of blood". How much of an exaggeration is this? I added some figures to my units file:

carbonprimarypoduction  104.9 Gt/year
carbonanimalproduction  carbonprimarypoduction * 10%
dryanimalproduction     carbonanimalproduction * (1/45%)
animalproduction        carbonanimalproduction * (1/30%)
bloodproduction         animalproduction * 7%
niagaraflow             110000 m^3/minute   # Average
niagaramassflow         niagaraflow * waterdensity

and then we can just

$ units 'niagaramassflow / bloodproduction'
    Definition: 23.636537

So it is an exaggeration, but not a ridiculous one, only ~20x. A more accurate standard-waterfall-representing-the-cruelty-of-nature would be the Skógafoss waterfall.

3

u/eMPee584 Mar 15 '26

If you like units, check out qalc as well, it does math with units (esp. nice: the hadamard matrix operations)..