Hi HN! This has been posted a few months ago (by someone else), but it wasn't really finished back then. The feedback I got here last time has helped a lot to improve all sorts of things. Looking forward to your comments!
I have only one minor issue: the REPL scrolling conflicts with the default scrolling acceleration on macOS. So just a very small movement on the trackpad and it scrolls all the way up or down. I believe this is due the "jquery-mousewheel" plugin [1].
This is pretty cool, it's one of the rare applications I've used where the things I've tried "just work". For example "10 kg to g", "c", "c to km s^(-1)", "c to km/s" all work intuitively. It's great it works at the command line too.
Something I wish I'd had when I was studying Physics.
It's not so basic though. Google knows the current value of most currencies, for instance. It's actually more efficient for the central servers to pull that data and the clients to query once in a while, rather than every single client (local calculator) to constantly keep all that data up to date. And that's just the currencies.
Your query doesn't exactly work though, it's interpreted as "paris at speed of sound". However "time between amsterdam and paris at the speed of sound in milliseconds" does work, returning 1.26*10^6 ms.
Oh wow, even microparsec/kilofortnight in m/s works now. This did not work for many years, and prompted me to write my only ever e-mail to Google with a complaint about 5 years ago.
Unfortunaetly, the conversion 30 miles per gallon in liter/100 km still displays an equal sign, which is technically wrong. However, this conversion is so useful, that I won't complain about it.
Yes. The underlying unit-conversion library is called https://github.com/sharkdp/purescript-quantities
It does not have a (nice) JavaScript API, so far, as it is written in PureScript - like Insect.
Thank you for the feedback. That is intentional. Whitespace (or even lack thereof, as in "2x") is implicit multiplication. Otherwise, you'd have to write multiplication signs everywhere:
Yes, whitespace as multiplication between number and unit or variable will be expected as multiplication but you can consider warning users about whitespace between two number literals because that could be just a typo.
This is on purpose (see operator precedence rules: https://github.com/sharkdp/insect#reference). Implicit multiplication (without an explicit multiplication operator) has a higher precedence than division in order for something like this to work:
tan(15cm/3m)
= tan(15cm/(3m))
On the other hand, explicit multiplication has a lower precedence than division, so you would have to write "1/12*c". I agree that it can be confusing at times (that's why there is a pretty printer), but I don't want the language/parser to be whitespace-aware.
That's because your unit conversion is invalid. It's entirely possible to construct an equation that computes mi/gal from L/km (or from gal/mi for that matter), but the dimmensionalty of the two numbers clearly disagree. Yes, you can introduce scenarios like yours where "any human" would know what the intended meaning of the question is, but mathematically speaking it's incorrect and encouraging a calculator to perform mathematically incorrect operations is a recipie for both disaster and the introduction of student/user misunderstandings.
Sure, because google isn't a calculator, it's an AI machine. Sometimes it guesses your intent right, sometimes it doesn't. That's fine for many tasks but not a great way to design a bridge or a steam boiler.
Yes, 100% agree with your comment. I'd rather have a calculator application that is maybe a little less "smart" in exchange for mathematical correctness and predictability.
I don't remember which calculator did this (I think GNU units), but I've seen this handled automatically with a warning saying "Warning: reciprocal conversion"
$ units
Currency exchange rates from www.timegenie.com on 2016-06-21
2926 units, 109 prefixes, 88 nonlinear units
You have: 7.8L/10km
You want: miles/gallon
reciprocal conversion
* 3.0155716
/ 0.33161209
I think it's fine for a calculator to make guesses as long as it makes it very clear that it's doing so.
Shameless plug for my http://dedo.io/, which is similar to this this, but with less features, more money-oriented and support for any custom units, e.g. if bag_weight = 12 kg / bag, then 10 bags * bag_weight is 120kg
A confusing thing is that the program seems to be using the purescript-quantity library which uses the purescript-decimals library which is arbitrary precision numbers, if I followed the dependencies correctly.
The readme also advertises it can deal with 10^(10^10), which it can (doubles can't deal with this, so it's definitely not just using Javascript doubles). The part which prints out numbers rounds to 6 places, but I don't see any place which rounds intermediate results.
Very nice on first try -- added to my quick toolbar.
Great to be able to intermix metric and SAE units, as there is (very unfortunate) constant use of both in my field of work.
Thank you! "bel" is already supported ("decibel" also, due to the handling of SI prefixes). Unfortunately, "dB" is parsed as "deci-byte". While this is not really a useful unit, this is on purpose (see https://github.com/sharkdp/insect/issues/67) in order to support "kB", "MB", etc. for "kilobyte", "megabyte", etc.
Automatic simplification (as opposed to explicit conversion) is a complex topic. There are a few simplifications that are already applied, for example:
20 L / m^2
= 0.02 m
You are absolutely right, it'd be nice to have "Pa·m²" be converted to "N" automatically. I've been thinking about simply going through a list of simple, standardized units (SI units like Newton) while trying to convert the result into these simple units. However, notice that this is not always what you want. If someone likes to compute in imperial units, we would rather leave all quantities in imperial units.
you could only apply simplifications that minimised the sum of the absolute value of all the unit exponents. that would be intuitively satisfying, and not require converting imperial to metric (which would leave the exponents unchanged)
Good suggestion, thank you! I was already thinking about some way to measure "perceived complexity" of a physical unit - this sounds like a very good try for such a heuristic.
Oh, I didn't know that :-)... that's interesting. I'm very much open for suggestions on how to improve the logo. I already went through a couple of iterations...
Actually it was just a "did you know?" comment, 99.99% of people don't know/care about it. I'd throw a SVG modification but I won't have my laptop around/time until Monday, when I'd just lower the upper wing a bit.
It has the ring of a know it all type of pedantic comment. I can safely assume that butterflys are deformed when they are pinned, I dont have to have a big expose revealing it as some hidden secret. Hackernews has the habbit of making disability level OCD seem like some grand hidden nugget that will make everyone think you are nerding better than everyone else.
Come on. This was an obvious reference to the article that was hot on HN recently.
Also while you "can safely assume that butterflys are deformed when they are pinned", you can also safely assume vast majority of the world doesn't know that, and you can also assume many people might want to reconsider using a dead butterfly as a symbol once they learn the image doesn't show what they thought it shows.
AKA regular, friendly, and completely warranted pedantry.
if you look at the previous thread(o) i think gp is either directly of indirectly referencing most of the comments therein are of the "now you've watched it you can't unwatch it" variety(i)
now, should a meta joke be the top comment about this tool? i suppose that is for the forum to decide..
but the op may find it useful information.. perhaps thae missed the previous thread
Thank you for the feedback. I'm not sure how to support this. I would probably have to call it "fluid_ounce" / "fl_oz" or "fl.oz." in order to distinguish it from the unit of mass.
Well, the way /usr/bin/units solves it is to allow "floz", "usfloz", "fluidounce", or "usfluidounce".
Having to learn that you can type "floz" is better than not being able to do it at all.
(You could also allow "fl oz", "fluid ounce", "fl ounce", etc. if you tweak your parser a little bit, but that's the deluxe version, and any functionality at all would be a big improvement.)
203 comments
[ 2.6 ms ] story [ 233 ms ] threadOld discussion: https://news.ycombinator.com/item?id=13909631
I have only one minor issue: the REPL scrolling conflicts with the default scrolling acceleration on macOS. So just a very small movement on the trackpad and it scrolls all the way up or down. I believe this is due the "jquery-mousewheel" plugin [1].
[1]: https://github.com/jquery/jquery-mousewheel/issues/36
I'll look into this. Thank you for the reference.
Something I wish I'd had when I was studying Physics.
Currencies I can understand hitting a remote server, but general unit conversion and basic arithmetic?
Unfortunaetly, the conversion 30 miles per gallon in liter/100 km still displays an equal sign, which is technically wrong. However, this conversion is so useful, that I won't complain about it.
10EUR + 11 USD + 1500 USD + 500CAD in ZAR
https://i.redditmedia.com/4FDIQLPJFtaOSXIDOlj6I9lCpVYdz8O06Y...
GNU Units is available under homebrew (as "gunits" IIRC).
If not, is the conversion logic in an npm package?
Still, it's pretty good.
≫ 1/12 c
This is on purpose (see operator precedence rules: https://github.com/sharkdp/insect#reference). Implicit multiplication (without an explicit multiplication operator) has a higher precedence than division in order for something like this to work:
On the other hand, explicit multiplication has a lower precedence than division, so you would have to write "1/12*c". I agree that it can be confusing at times (that's why there is a pretty printer), but I don't want the language/parser to be whitespace-aware.1/4 s - > (1/4) s
1 m / 4 s - > (1 m) / (4 s)
≫ exp(2*kg/s)
Excellent!Is there any way I can save a list of variables to file and then reload them?
I also would like to vote for supporting imaginary numbers (Issue #47).
> Is there any way I can save a list of variables to file and then reload hem?
Not yet, no - thank you for the suggestion. The command-line version can read from a file, though (https://github.com/sharkdp/insect/issues/40)
https://www.google.com/search?q=5+l/100km+to+mpg&ie=UTF-8&oe...
I use the similar Soulver on my Mac and iOS devices.
I probably mostly use Numi for unit conversions, but asked for in a 'human' way. eg "68 square meters in square feet"
http://mathnotepad.com https://arve0.github.io/webcas/
The readme also advertises it can deal with 10^(10^10), which it can (doubles can't deal with this, so it's definitely not just using Javascript doubles). The part which prints out numbers rounds to 6 places, but I don't see any place which rounds intermediate results.
Edit: Found where 30 digits comes in. https://github.com/sharkdp/purescript-decimals/blob/ad719fc7...
Any hope of an Android app version soon?
Quick workaround:
≫ Meaning = 6
≫ of = 1
≫ life = 7
Meaning = 7
of = 2
Life = 4
Automatic simplification (as opposed to explicit conversion) is a complex topic. There are a few simplifications that are already applied, for example:
You are absolutely right, it'd be nice to have "Pa·m²" be converted to "N" automatically. I've been thinking about simply going through a list of simple, standardized units (SI units like Newton) while trying to convert the result into these simple units. However, notice that this is not always what you want. If someone likes to compute in imperial units, we would rather leave all quantities in imperial units.https://github.com/sharkdp/insect/blob/master/media/insect.s...
Also while you "can safely assume that butterflys are deformed when they are pinned", you can also safely assume vast majority of the world doesn't know that, and you can also assume many people might want to reconsider using a dead butterfly as a symbol once they learn the image doesn't show what they thought it shows.
AKA regular, friendly, and completely warranted pedantry.
if you look at the previous thread(o) i think gp is either directly of indirectly referencing most of the comments therein are of the "now you've watched it you can't unwatch it" variety(i)
now, should a meta joke be the top comment about this tool? i suppose that is for the forum to decide..
but the op may find it useful information.. perhaps thae missed the previous thread
op: awesome tool
(o) https://news.ycombinator.com/item?id=14460013
(i) https://www.youtube.com/watch?v=JeIJ8l3PZ88
Remember Graphing Calculator? That could use such features.
Autodesk Inventor understands units in formulas, but mostly for length and angle. Everything becomes meters internally.
E.g. "6Mbit/s * 1.5h as GB"
I've been using it for a while now and I can't imagine going back to a traditional calculator
I tried "4 tbsp to oz" and it interprets oz as mass instead of volume. Google correctly gives me 2 as the answer.
Having to learn that you can type "floz" is better than not being able to do it at all.
(You could also allow "fl oz", "fluid ounce", "fl ounce", etc. if you tweak your parser a little bit, but that's the deluxe version, and any functionality at all would be a big improvement.)