1. 8

  2. 6


    > 2min * 3hours
    1. 2

      What answer did you expect?

      1. 6

        I think I’d expect it to report the result in either min² or h². It’s not wrong per se, but to take a non-time example, I think if I gave you dimensions of a road in terms of how many meters wide and km long it is, and then asked for the surface area of the road, I’d expect an answer in either m² or km², not m·km.

        edit: Having actually read the help, it looks like it does support this, but only if you request the result in specific units. Otherwise it just naively compounds the units of the input. One of the examples in the help is that 6Mbit/s * 1.5h -> Gb gives you 4.05Gb. But if you type just 6Mbit/s * 1.5h, you get 9Mbit·h/s; it doesn’t attempt to simplify the units by default.

        1. 1

          Update: I discovered that there is already a GitHub issue for this wishlist item.

        2. 1

          i’d expect an error, because it doesn’t make sense. (note that you get an error with 2min * 3hours -> min)

          1. 3

            You get an error on the latter one because the unit you get from multiplying two times together is [time]², not [time]. If you instead ask for 2min * 3hours -> min², there’s no error.

            Granted, squared time on its own doesn’t have a physical meaning, but it appears frequently in other expressions. For example, this works correctly: 1kg * 32miles / (2min * 3hours) -> N.

      2. 1

        https://frinklang.org/ - “Frink is a practical calculating tool and programming language designed to make physical calculations simple, to help ensure that answers come out right, and to make a tool that’s really useful in the real world. It tracks units of measure (feet, meters, kilograms, watts, etc.) through all calculations, allowing you to mix units of measure transparently, and helps you easily verify that your answers make sense. It also contains a large data file of physical quantities, freeing you from having to look them up, and freeing you to make effortless calculations without getting bogged down in the mechanics.”

        This might provide answers closer to what many here in the comments would expect, including throwing an error for the non-time example.

        $ frink

        Frink - Copyright 2000-2015 Alan Eliasen, eliasen@mindspring.com.

        2 min + 3 hours

        10920 s (time)

        2 min + 3 hours -> hours

        91/30 (approx. 3.0333333333333333)

        2 min * 3 hours

        1296000 s^2 (unknown unit type)

        I’ve not looked at insect in depth, but I wonder if the authors are aware of frink as prior art.

        1. 1

          The biggest downside of Frink is that it’s only available as a Java applet, making it pretty inconvenient to quickly access it in a shell (or even through a web browser now that Java is disappearing there too).

          1. 1

            All you need to do is create an alias or a simple script:

            rlwrap java -server -Xmx500M -classpath frink.jar frink.gui.FrinkStarter “$@”

            I totally forgot it was Java, actually. Wall clock time for a null result is reported as 1.2s on a semi-modern VPS using OpenJDK 8, making startup performance not much less painful than, say, Julia.