54 votes

"A calculator app? Anyone could make that."

7 comments

  1. smores
    Link
    This is giving me serious flashbacks to my data structures and functional programming course. It was taught by a very mathy professor, and one of the projects required implementing real numbers...

    This is giving me serious flashbacks to my data structures and functional programming course. It was taught by a very mathy professor, and one of the projects required implementing real numbers from scratch (I found the assignment online!! https://www.cs.cornell.edu/courses/cs3110/2013fa/hw/4/ps4.pdf). Truly fascinating, like really made me rethink a lot of what I thought I knew about both numbers and programming. And just like in this post, “Your implementations of === and is_non_neg are not required to terminate, but they should terminate when possible.”

    The part of this post that continues past RRA into symbolic representations was such a great example of computer science crossing over into software engineering. Taking a problem that’s essentially impossible to solve “correctly,” and finding the solution that most closely approximates the correct answer for the largest number of use cases. I love it!

    13 votes
  2. Akir
    Link
    This article has been bugging me since I read it and I finally realized why. It makes a false assertion at the very beginning. But that is not what a calculator does. A calculator calculates...

    This article has been bugging me since I read it and I finally realized why. It makes a false assertion at the very beginning.

    A calculator should show you the result of the mathematical expression you entered.

    But that is not what a calculator does. A calculator calculates arithmetic, but is not smart enough to resolve functions. What they are describing is a Computer Algebra System. A CAS will not use floating points to describe non-decimal numbers and when you give it a division problem that cannot resolve into a whole number, it will return a fraction unless otherwise configured.

    Of course, making a CAS is difficult for the reasons the author mentioned and then some. Which is why most people who work on calculators try to avoid doing so. There are quite a few physical and computer calculators that use Giac, for instance. People who dunk on the price of TI calculators usually fail to grasp that the thing that makes them valuable is not the hardware, but the software it is running.

    One could say that the difference between a calculator and a CAS is scope. The iOS calculator is actually nicer than most calculators because it can evaluate algebraic expressions and it does have “scientific” functions for geometry and physics calculations, but the reason why it’s not as precise as the Android calculator is simply that it doesn’t need to be. I think there’s at least some merit to the argument that the Android calculator being so over engineered means this guy got to spend far more time and effort into the project than necessary.

    Of course there is no single dividing line between a calculator and a CAS. But if you are familiar with this type of math where calculators start failing you, you probably already know that you should evaluate your tools to see if they are capable of doing these advanced features and not to trust them blindly.

    12 votes
  3. Banazir
    Link
    A few days ago, I helped a streamer I watch with part of her display. The section that showed total donations would occasionally show something like $1.2300000000006, which annoyed her because it...

    A few days ago, I helped a streamer I watch with part of her display. The section that showed total donations would occasionally show something like $1.2300000000006, which annoyed her because it would cause the text to go outside the boundary of where it was supposed to go. I'm a regular enough viewer that she trusted me when I asked for the JavaScript code handling events and updating the display, and a quick .toFixed(2) was enough to clean up the error completely.

    I saw this article on HN a couple days ago and shared it with her community, since the first few paragraphs are a good intro about why the issue happens. I decided not to dive deeper into it, since she's not a technical person and the details would bore her, but I found the timing convenient and a bit of a Baader-Meinhof Phenomenon. Either way, this kind of problem is incredibly interesting to me, and I am still disappointed by how little the courses in my comp sci degree actually touched on information theory and data representation.

    5 votes
  4. [2]
    bln
    Link
    If one wanted to write a calculator app, I wonder what math library he could use to ensure correctness then.

    If one wanted to write a calculator app, I wonder what math library he could use to ensure correctness then.

    4 votes
    1. vord
      Link Parent
      From the sounds of it, fork the Android calculator.

      From the sounds of it, fork the Android calculator.

      5 votes
  5. krellor
    Link
    That was a fun read. I had a chuckle at the end because when I read the first few lines I thought "why not symbolic representation?" Then I forgot about that as I was entertained by the journey,...

    That was a fun read. I had a chuckle at the end because when I read the first few lines I thought "why not symbolic representation?" Then I forgot about that as I was entertained by the journey, only to have them end at symbolic representation, but in a way that makes it efficient enough to run on a phone calculator app.

    4 votes
  6. PeeingRedAgain
    Link
    This is part of the reason Mathematica amazes me. I know how to code and I know calculus, but I don't even know where to start when it comes down to programmatically outputting simplified...

    This is part of the reason Mathematica amazes me. I know how to code and I know calculus, but I don't even know where to start when it comes down to programmatically outputting simplified expressions containing differentials and integrals...

    2 votes