Hacker News new | ask | show | jobs
by mike_d 1690 days ago
Also a frequent WA user. I use it for things I could calculate, but are much faster to just ask in plain text.

How much that cloud instance really costs

  $0.03/hr * 1 month
Bandwidth calculations for hosting providers

  10 TB per month in Mbps
6 comments

you might want to try units(1).

https://www.gnu.org/software/units/units.html

the input language is less flexible than wolframalpha/google, but i quickly got used to it. it's nice to have something local and reliable. you can also define custom units.

i prefer using it in terse mode:

    $ units -t 0.03$/hr*1month
    21.914532 US$
    $ units -t 10TB/month Mbps
    30.421214
qalc[1] is also quite nice if you're looking for a command line calculator; it handles units well, but has some other fancy features, and has a very lax parser which i find to be a huge plus.

    $ qalc '0.03$/hr*1month'
    error: "r" is not a valid variable/function/unit.
    (0.03 × (USD / hour)) × (1 × month) = $21.915

    $ qalc '0.03$/h*1month -> CAD'
    (0.03 × (USD / hour)) × (1 × month) ≈ CAD 27.28388011

    $ qalc '10TB/month -> Mbit/s'
    10 × (terabyte / month) ≈ 30.42056430 megabits/s

    $ qalc 'integrate(x+x^2)'
    integrate(x + (x^2)) = x^3 / 3 + x^2 / 2 + C
[1] https://qalculate.github.io/manual/qalc.html
Units advises there are 118.20896 smoots per furlong..
Wouldn’t that be properly expressed as 118 Smoots plus 5 Ears?
people still measuring in smoots smh
For calculator problems like that, I use J:

   */ 0.03 24 30
21.6

   1e6 %~ (10e12 * 8) % */ 30 24 3600
30.8642

Usually requires some massaging, but still takes seconds.

While APL dialects are very nice for this sort of thing, they generally don't understand units of measure or know about physical constants; you have to put those into them yourself. Here are some of my recent units(1) queries:

    141 pounds force 30 mm  # in joules
    1160/4
    log(3)/3/(log(2)/2)  # how much more efficient is one-hot ternary than one-hot binary?
    5V 7 μs / 7.3 A
    .0117% half avogadro mol / 1.251e9 years / (potassium+chlorine)g  # how radioactive is lite salt?
    3.27$/gallon  # in $/liter
    sqrt(2 2000 electronvolt/electronmass)
    18.8 foot pounds force # in joules
    163$/(7.9 g/cc * 1500 mm 3000 mm 3.2 mm)  # cold rolled steel price is higher than steel sold by weight
    m3/4 / 15 cfh
    2 pi sqrt(200 um / gravity)
Julia is also excellent for working with units (Units.jl, IIRC).
Unitful.jl
Yeah, it's great for these types of things. It also has a bunch of values built in, so you can do things like:

  (day length of jupiter) * 80
Same here, the way it seamlessly wrangles even the most ridiculous combinations of units is insanely useful. Just yesterday I used it to calculate power consumption for a house by timing one of those spinning wheel meter things. Something like "(10 rot / 46 s) / (375 rot / kW*h)" and it gave me straight answer in watts.

I definitely could've worked that out by hand, but it would've taken a minute or a few, mostly on unit conversions. With WA, I can just think in variable relationships and not worry about units at all.

Don't get me wrong, it often returns complete garbage, see all the memes of Siri passing non-math questions to it. It's annoying to figure out or explain to someone because the syntax is very loose and you just kind of need to get a feel for it, but once you do, it's really powerful.

I use Google for those pretty often.
I do the same for basic calculations. I was surprised things like 9:00 EST in CET don‘t work in google search, but do in WA.
You are absolutely right. I misremembered. Using GMT does indeed work only on WA:

9:00 GMT-7 in CET

https://www.google.com/search?channel=fs&client=ubuntu&q=9%3...

https://www.wolframalpha.com/input/?i=9%3A00+GMT-7+in+CET

Google handles GMT and UTC but doesn't handle offsets from there and, frankly, it's understandable and I wouldn't bother either. What it does handle though is countries and their DST settings:

> 9:00 UTC in Thailand

Ohh does WA respect time zones in searches?

A regular complaint I have with google is (simplified example) converting EDT to MST. Google will “helpfully” correct me and convert EDT to MDT instead, which is explicitly not what I asked for. It’s stupid (I can usually figure it out on my own) but that would be a huge win for me.

You also might want to try google search. They display calculations for these particular queries and quite a few more.
Google is also often wrong. For example, my computer is set to US English, as is my profile. Yet somehow it still gets confused on decimals and commas (they are switched in my current country’s locale).
Also, if you use the Firefox search bar only the first 20 chars are sent to google, so longer calculations are truncated before they're calculated and wrong answers come back with no warning. Not a Google problem per se but a risk of using Google to calculate still.
or frink [1], which started off as a tool like the others mentiond here, but is now a full fledged units-based programming language. See some examples of them here [2]

1: https://frinklang.org/ 2: https://frinklang.org/#SampleCalculations

Its been on HN before.