[HN Gopher] "A calculator app? Anyone could make that"
___________________________________________________________________
"A calculator app? Anyone could make that"
Author : pie_flavor
Score : 1079 points
Date : 2025-02-16 10:16 UTC (12 hours ago)
(HTM) web link (chadnauseam.com)
(TXT) w3m dump (chadnauseam.com)
| coder543 wrote:
| The link at the end is both shortened (for tracking purposes?)
| _and_ unclickable... so that's unfortunate. Here is the real link
| to the paper, in a clickable format:
| https://dl.acm.org/doi/pdf/10.1145/3385412.3386037
| ChadNauseam wrote:
| Thanks for pointing that out. It should be fixed now. The
| shortening was done by the editor I was using ("Buffer") to
| draft the tweets in - I wasn't intending to track one but it
| probably does provide some means of seeing how many people
| clicked the link
| est wrote:
| if "answer" overflows, switch to symbolic mode.
| anon-3988 wrote:
| not that simple, 1/3 + 5 - 1/3 should be 5. It doesn't overflow
| in IEEE754
| coder543 wrote:
| That _does_ appear to equal exactly 5... would you care to
| show how it doesn 't? $ cat check_math.c
| #include <stdio.h> int main() { //
| Define the values as float (32-bit floating point)
| float one_third = 1.0f / 3.0f; float five = 5.0f;
| // Compute the equation float result = one_third
| + five - one_third; // Check for exact
| equality if (result == five) {
| printf("The equation evaluates EXACTLY to 5.0 (True)\n");
| } else { // Print the actual result and the
| difference printf("The equation does NOT
| evaluate exactly to 5.0 (False)\n");
| printf("Computed result: %.10f\n", result);
| printf("Difference: %.10f\n", result - five); }
| return 0; } $ gcc -O0 check_math.c -o
| check_math; ./check_math The equation evaluates
| EXACTLY to 5.0 (True)
| roenxi wrote:
| > And almost all numbers cannot be expressed in IEEE floating
| points.
|
| It is a bit stronger than that. Almost all numbers cannot be
| practically expressed and it may even be that the probability of
| a random number being theoretically indescribable is about 100%.
| Depending on what a number is.
|
| > Some problems can be avoided if you use bignums.
|
| Or that. My momentary existential angst has been assuaged. Thanks
| bignums.
| mananaysiempre wrote:
| > existential angst
|
| The best (and most educational) expression of that angst that I
| know: https://mathwithbaddrawings.com/2016/12/28/why-the-
| number-li....
| roenxi wrote:
| Uncomputable! That was the word I wanted. I only remembered
| constructability but that was something else. Thanks.
| TeMPOraL wrote:
| Wait. Could we in principle find more ways to express some of
| those uncomputable numbers, or have we conclusively proven we
| just can't reach them - can't identify any of them in any way
| we could express?
|
| EDIT: let me guess - there is a proof, and it's probably a
| flavor of the diagonal argument, right?
| analog31 wrote:
| Yes there's a proof. One flavor is that in any system for
| expressing numbers using symbols, you can show a
| correspondence between finite strings of symbols, and whole
| numbers. So, what works for whole numbers also works for
| things like proofs and formulas. I think the correspondence
| may be called "Goedel numbering."
| throw0000111 wrote:
| There are two ways to read that question.
|
| If hypercomputation is possible, then there might be a way
| to express some of those uncomputable numbers. They just
| won't be possible with an ordinary Turing machine.
|
| (If description is all you need, then it's already possible
| to describe some uncomputable numbers like Chaitin's
| constant. But you can't reliably list its digits on an
| ordinary computer.)
|
| As for the other interpretation, "have we conclusively
| proven we can't reach them with an ordinary computer",
| IIRC, the proof that there are infinite uncomputable
| numbers is as follows: Consider a finitely large program
| that, when run, outputs the number in question. This
| program can be encoded as an integer - just read its
| (binary or source) bytes as a very large base-256 number.
| Since the set of possible programs is no larger than the
| set of integers, it's (at most) countably infinite.
| However, the real numbers are uncountably infinite. Thus a
| real number is almost never computable.
| mananaysiempre wrote:
| For all real numbers in bulk-- You may call it a diagonal
| argument, but it's just a reduction to Cantor's original
| statement, no new proof needed. There are only countably
| many computable numbers, because there are only countably
| many programs, because there are only countably many finite
| strings over any finite alphabet[1].
|
| For individual real numbers-- There are of course provably
| uncomputable ones. Chaitin's constant is the poster child
| of these, but you could just take a map of (number of
| Turing machine in any numbering of all of them) to
| (terminates or not) and call that a binary fraction. (This
| is actually not far away from Chaitin's constant, but the
| actual one is reweighted a bit to make it more meaningful.)
| Are there _un_ provably uncomputable ones? At a guess I'd
| say so, but I'm not good enough to give a construction
| offhand.
|
| [1] A countable union of (finite or) countable sets is
| finite. Rahzrengr gur havba nf sbyybjf: svefg vgrz bs svefg
| frg; frpbaq vgrz bs svefg frg, svefg vgrz bs frpbaq frg;
| guveq vgrz bs svefg frg, frpbaq vgrz bs frpbaq frg, svefg
| vgrz bs guveq frg; rgp. Vg'f snveyl boivbhf gung guvf
| jbexf, ohg vs lbh jnag gb jevgr gur vairefr znccvat
| rkcyvpvgyl lbh pna qenj guvf nf n yvar guebhtu gur vagrtre
| cbvagf bs n dhnqenag.
| umanwizard wrote:
| The proof of the existence of uncomputable numbers is very
| simple: there are countably many computer programs, but
| uncountably many numbers.
| GMoromisato wrote:
| BTW: I tried constructing a new number that could not be
| computed by any other Turing machine using a variant of the
| diagonilization argument. Basically, enumerate all Turing
| machines that generate numbers:
|
| Turing machine 1
|
| Turing machine 2
|
| Turing machine 3
|
| ...
|
| Now construct a new Turing machine that produce a new
| number in which the first digit is the first digit of
| Turing machine 1, the second is the second digit of Turing
| machine 2, etc. Now add 1 (with wrap-around) to each digit.
|
| This will generate a new number that cannot be generated by
| any of the existing Turing machines.
|
| The bug with this argument (as ChatGPT pointed out) is that
| because of the halting problem, we cannot guarantee that
| any specific Turing machine will halt, so the constructed
| program will not halt, and thus cannot actually compute a
| number.
| ThrowawayR2 wrote:
| SMBC manages to do it in a 4 panel comic: https://www.smbc-
| comics.com/comic/real-4
| leereeves wrote:
| > Almost all numbers cannot be practically expressed
|
| That's certainly true, but all numbers that can be entered on a
| calculator can be expressed (for example, by the button
| sequence entered in the calculator). The calculator app can't
| help with the numbers that can't be practically expressed, it
| just needs to accurately approximate the ones that can.
| tialaramex wrote:
| This behaviour is what you get in say a cheap 1980s digital
| calculator, but it's not what we actually want. We want
| correct answers and to do that you need to be smarter.
| Ideally impossibly smart, but if the calculator is smarter
| than the person operating it that's a good start.
|
| You're correct that the use of the calculator means we're
| talking about computable numbers, so that's nice - almost all
| Reals are non-computable but we ruled those out because we're
| using a calculator. However just because our results are
| Computable doesn't let us off the hook. There's a difference
| between knowing the answer is exactly 40 and knowing only
| that you've computed a few hundred decimal places after 40
| and so far they're all zero, maybe the next one won't be.
| kqr wrote:
| > There's a difference between knowing the answer is
| exactly 40 and knowing only that you've computed a few
| hundred decimal places after 40 and so far they're all
| zero, maybe the next one won't be.
|
| I would guess that if you pulled in a random sample of 2000
| users of pocket calculators and surveyed their use cases
| you would find a grand total of 0 of them in which the cost
| function evaluated on a hundredth-decimal place error is at
| all meaningful.
|
| In other words, no, that difference is not meaningful to a
| user of a pocket calculator.
| lupire wrote:
| What don't seriously curious people deserve pocket
| calculators?
| Dylan16807 wrote:
| Are you implying that "seriously curious people" as a
| group need more than a hundred digits? If so, I don't
| think I agree.
|
| Otherwise I can't figure out what you mean.
| tialaramex wrote:
| The sine of x is 0 when x is any integer multiple of pi -
| it's not approximately zero, it's really zero, actual
| zero. So clearly some formulae can actually be zero. If
| I'm curious, I might wonder whether eventually the
| formula e * -x reaches zero for some x
|
| e * -10 is about 0.000045399929 and presumably you agree
| that's not zero
|
| e * -100 is about 3.72 times 10 * -44, is that still not
| zero? An IEEE single precision floating point number has
| a non-zero representation for this, although it is a
| denormal meaning there's not very much precision left...
|
| e * -1000 is about 5.075 times 10 * -435 and so it won't
| fit in the IEEE single or double precision types. So they
| both call this zero. Is it zero?
|
| If you take the naive approach you've described, the
| answer apparently is yes, non-zero numbers are zero. Huh.
| nkrisc wrote:
| If I'm using a pocket calculator for a problem then for all
| intents and purposes 1x10-40 = 0
| GMoromisato wrote:
| Does it matter that some numbers are inexpressible (i.e.,
| cannot be computed)?
|
| I don't think it matters on a practical level--it's not like
| the cure for cancer is embedded in an inexpressible number
| (because the cure to cancer has to be a computable number,
| otherwise, we couldn't actually cure cancer).
|
| But does it matter from a theoretical/math perspective? Are
| there some theorems or proofs that we cannot access because of
| inexpressible numbers?
|
| [Forgive my ignorance--I'm just a dumb programmer.]
| lupire wrote:
| It doesn't "matter", but it's interesting to probe the
| boundary between the easily accessible world and the probably
| inaccessible world.
|
| Non-discrete real-number-based Fractals are a beautiful
| visual version of this.
| yen223 wrote:
| We know of at least one uncomputable number - Chaitin's
| constant, the probability that any given Turing machine
| halts.
|
| Personally, I do wonder sometimes if real-world physical
| processes can involve uncomputable numbers. Can an object be
| placed X units away from some point, where X is an
| uncomputable number? The implications would be really
| interesting, no matter whether the answer is yes or no.
| kccqzy wrote:
| Well some classical techniques in standard undergraduate real
| analysis could lead to numbers outside the set of computable
| numbers, so if you don't allow non-computable numbers you
| will need to be more careful in the theorems you derive in
| real analysis. I do not believe that is important however;
| it's much simpler to just work with the set of real numbers
| rather than the set of computable numbers.
| ChadNauseam wrote:
| I worded that sentence carefully, when I said "almost all" :)
| jwmoz wrote:
| Not a calculator engineer but this seems hideously complex?
| tim-kt wrote:
| For an everyday use calculator? Sure. It's still fun and
| challenging to create a calculator that can handle "as much"
| math/arithmetics as possible.
| grandempire wrote:
| It's really not just for experts though. Even dealing with
| fractions is going to require more than a naive
| implementation.
| dgacmu wrote:
| Maybe, though in the paper (not the article):
|
| > We no longer receive bug reports about inaccurate results, as
| we occasionally did for the 2014 floating-point-based
| calculator
|
| (with a footnote: This excludes reports from one or two bugs
| that have now been fixed for many months. Unfortunately, we
| continue to receive complaints about incorrect results, mostly
| for two reasons. Users often do not understand the difference
| between degrees and radians. Second, there is no standard way
| to parse calculator expressions. 1 + 10% is 0.11. 10% is 0.1.
| What's 10% + 10%?)
|
| When you have 3 billion users, I can imagine that getting rid
| of bugs that only affect 0.001% of your userbase is still
| worthwhile and probably pays for itself in reduced support
| costs.
| Aardwolf wrote:
| > 1 + 10% is 0.11.
|
| I know adding % has multiple conventions, but this one seems
| odd, I'd interpret 1 + 10% as "one plus 10 percent of one"
| which is 1.1, or as 1 + 10 / 100 which happens to be also 1.1
| here
|
| The only interpretation that'd make it 0.11 is if it
| represents 1% + 10%, but then the question of 10% + 10% is
| answered: 0.2 or 20%. Or maybe there's a typo and it was
| supposed to say "0.1 + 10%"
| BoiledCabbage wrote:
| 1 + 10% could parse like the following:
|
| (1+10)%
|
| Which is 11% or 0.11
| jtbayly wrote:
| I'm confused. Why would 1 + 10% obviously be 0.11?
|
| I expected 1.1 (which is what my iOS calculator reported,
| when I got curious).
|
| I do understand the question of parsing. I just struggle to
| understand why the first one is confidently stated to
| correctly result in a particular answer. It feels like a
| perfect example itself of a problem with unclear parsing.
| athrowaway3z wrote:
| I think a big issue with how we teach math, is the casualness
| with which we introduce children to floating points.
|
| Its like: Hey little Bobby, now that you can count here are the
| ints and multiplication/division. For the rest of your life
| there will be things to learn about them and their algebra.
|
| Tomorrow we'll learn how to put a ".25" behind it. Nothing
| serious. Just adds multiple different types of infinities with
| profound impact on exactness and computability, which you have
| yet to learn about. But it lets you write 1/4 without a
| fraction which means its simple!
| layer8 wrote:
| There is no floating point here.
| criddell wrote:
| > For the rest of your life there will be things to learn
| about them and their algebra.
|
| That's just not true for the vast majority of people.
| itishappy wrote:
| It's available to learn whether or not they take advantage
| of it.
| itishappy wrote:
| Totally agree. It bothered me when I was younger, though I
| had no idea how to explain why, but this should be deeply
| unsettling to everyone who encounters it:
| 1/4 = 0.25 exact 1/3 = 0.333... infinitely
| repeating approximation
| grandempire wrote:
| Oh that number? It's just a Laurent series. Just take the
| limit of the partial sums.
| itishappy wrote:
| 1/1 a 1/2 ah 1/3 aH! 1/4 ahh
| 1/5 ah 1/6 ahH! 1/7 aHHHHHH! 1/8
| ahhh 1/9 aH! 1/10 ah 1/11 aHH!
| 1/12 ahhH! 1/13 aHHHHHH! 1/14 ahHHHHHH!
| 1/15 ahH! 1/16 ahhhh 1/17
| aHHHHHHHHHHHHHHHH! 1/18 ahH! 1/19
| aHHHHHHHHHHHHHHHHHH! 1/20 ahh
|
| https://en.wikipedia.org/wiki/Repeating_decimal#Table_of_va
| l...
| grandempire wrote:
| Real numbers are quite complex (no pun). Understanding the
| material well is a junior level math major course.
|
| If you really understand the existing math curriculum this
| should be high school level.
| xixixao wrote:
| Great resource! For my calculator I also wanted to tackle
| physics, which expands on the number definition with measurement
| error size.
|
| It is suprisingly hard problem.
|
| https://recomputer.github.io/
| ConanRus wrote:
| yours give 1 on (10^100)+1-(10^100), cool
| Shorel wrote:
| Almost no one has done that calculator app, properly. When I mean
| properly, I mean a complete calculator, like the TI-89.
|
| I am using, in Android, and emulator for the TI-89 calculator.
|
| Because no Android app has half the features, and works as well.
| anthk wrote:
| Maxima
| Shorel wrote:
| Yep, I use that in the laptop. But the smartphone still needs
| a good one calculator App.
| lupire wrote:
| Geogebra and Desmos
| orbital-decay wrote:
| It's not even about features. Calculators are mostly useful for
| napkin math - if I can't afford an error, I'll take some full-
| fledged math software/package and write a program that will be
| debuggable, testable, and have version control.
|
| But for some reason the authors of calculator apps never
| optimize them for the number of keypresses, unlike Casio/TI/HP.
| It's a lost art. Even a simple operator repetition is a
| completely alien concept for new apps. Even the devs of the
| apps that are supposed to be snappy, like speedcrunch, seem to
| completely misunderstand the niche of a calculator, are they
| not using it themselves? Calculator is neither a CAS nor a
| REPL.
|
| For Android in particular, I've only found two non-emulated
| calculators worth using for that, HiPER Calc and 10BA by
| Segitiga.Pro. And I'm not sure I can trust the correctness.
| cgcrob wrote:
| Proper ones are certainly usable for more than napkin math. I
| deal with fairly simple definite integrals and linear algebra
| occasionally. It's easier for me to plug this into a
| programmable calculator than it is to scratch in the dirt on
| Maxima or Mathematica most of the time if I just need an
| answer.
| jfengel wrote:
| I find that much of the time I want WolframAlpha for when
| basic arithmetic, because I like the way it tracks and
| converts units. It's such a simple way to check that my
| calculation isn't completely off base. If I forget to square
| something or I multiply when I meant to divide I get an
| obviously wrong answer.
|
| Plus of course not having to do even more arithmetic when one
| site gives me kilograms and another gives me ounces.
| Aachen wrote:
| qalc also tracks and converts units, and is open source
| (practical benefit: runs offline). I have it on Android via
| a Debian subsystem but just checked and Termux simply has
| it also (pkg install qalc)
|
| Random example off the top of my head to show off some
| features: say it takes 5 minutes to get to space, and I
| heard you come around every 90 minutes, but there's
| differing definitions on whether space is 80 or 100 km
| above the surface, then if you're curious about the G
| forces during launch: (2*pi*(6350+
| 90+-10)km / 90 minutes) / 5 minutes to gees
| ((2 x pi x ((6350 + 90+-10) kilometers)) / (90 minutes)) /
| (5 minutes) [?] 2.5470+-0.0040 gees
|
| (the output has color coding for units, constants, numbers,
| and operators)
|
| It understands unicode plusminus for uncertainty tracking,
| units, function calls like log(n,base), find factors, it
| will do currencies too if you let it download a table from
| the internet... I love this software package. (No
| affiliation, just a happy user who discovered this way too
| late in life)
|
| It's not as clever as WolframAlpha, no natural language
| parsing or Pokedex functions (sometimes I do wish that it
| knew things like Earth radii), but it also runs anywhere
| and never tells you the computation took too long and so
| was cancelled
|
| Edit: I just learned there's now also an Android app!
| https://github.com/jherkenhoff/qalculate-android |
| https://f-droid.org/packages/com.jherkenhoff.qalculate/
| I've checked before and there wasn't back then, so this is
| cool. This version says it supports graph plotting which
| the command-line version doesn't do
| kqr wrote:
| If you're willing to learn to work with RPN calculators
| (which I think is a good idea), I can recommend RealCalc for
| Android. It has an RPN mode that is very economic in
| keypresses and it's clear the developers understand how
| touchscreens work and how that ties into the kind of work
| pocket calculators are useful for.
|
| My only gripe with it is that it doesn't solve compounding
| return equations, but for that one can use an emulated
| HP-12c.
| HachiWari8 wrote:
| RealCalc Plus is great on the Android side. If using
| iPhone/iPad/macOS, try BVCalc. Its RPN mode shows you the
| algebraic expression (i.e., using infix notation display)
| for each item on the stack, which both helps you check for
| entry mistakes and also more easily keep track of what each
| stack item represents. I haven't found another RPN
| calculator that can do this.
| vegesm wrote:
| I'm the developer of an Android calculator, called Algeo [1]
| and I wonder which part of it that makes it feel like
| slow/not snappy? I'm trying to constantly improve it, though
| UX is a hard problem.
|
| [1] - https://play.google.com/store/apps/details?id=com.algeo
| .alge...
| cgcrob wrote:
| Yes that. I use free42 on my phone and mac. And an actual real
| HP 42S.
|
| Edit: and Maxima as well on the mac (to back up another user's
| comment)
| readyplayernull wrote:
| Another app nobody has made is a simple random music player.
| Tried VLC on Android and adding 5000+ songs from SD card into a
| playlist for shuffling simply crashes the app. Why do we need a
| play list anyway, just play the folder! Is it trying to load
| the whole list at the same time into memory? VLC always works,
| but not on this task. Found another player that doesn't require
| building a playlist but when the app is restarted it starts
| from the same song following the same random seed. Either save
| the last one or let me set the seed!
| zimpenfish wrote:
| > Another app nobody has made is a simple random music
| player.
|
| Marvis on iOS is pretty good at this. I use it to shuffle
| music with some rules ("low skip %, not added recently, not
| listened to recently")[0] and it always does a good job.
|
| [0] Because "create playlist" is still broken in iOS
| Shortcuts, incredibly.
| teknopaul wrote:
| I suspect nobody made xxx vlc plug-in because compiling it is
| far too hard.
|
| I tried to make a joystick controller for a particular use
| case on one platform (Linux) and I gave up.
|
| VLC solves a hard problem. Supporting lots of different libs,
| versions, platforms, hardware and on top of that licensing
| issues.
| bobsmooth wrote:
| The Samsung music player can do that but you need a Samsung
| phone.
| readyplayernull wrote:
| Tried it but it can only add up to 1000 songs per playlist.
| crtasm wrote:
| Vanilla Music can play and shuffle an entire folder
| readyplayernull wrote:
| Searching for Vanilla Music in Google Play shows every
| other player except that one, which reminds me nobody makes
| search engines anymore.
| nolist_policy wrote:
| Vanilla Music isn't on the Play store, get it from
| F-Droid.
| teddyh wrote:
| <https://f-droid.org/en/packages/ch.blinkenlights.android
| .van...>
| crtasm wrote:
| Thanks, I didn't know it was no longer on there.
|
| https://github.com/vanilla-music/vanilla >Note: As of 23.
| Jun 2024, Vanilla Music is no longer available in the
| Google Play store: I simply don't have time to comply
| with random policy changes and verification requests. Any
| release you see there is probably an ad-infested fork
| uploaded by someone else.
| oneshtein wrote:
| I prefer Vinyl Music Player: https://f-droid.org/en/packa
| ges/com.poupa.vinylmusicplayer/
| amenod wrote:
| Just tried it... Couldn't figure out in 5 minutes how to
| add files to a playlist. Pass.
| crtasm wrote:
| GP didn't want to use a playlist.
|
| To create and add to one: long-press on a
| file/folder/track/album for the context menu or use the
| ... menu while in the now playing screen.
|
| https://github.com/vanilla-music/vanilla
| FpUser wrote:
| Foobar2000 has no problems in these areas
| readyplayernull wrote:
| Tried it, but seems to use the system's modal to add
| folders, that blocks the SD card folder due to "privacy
| reasons", even after giving the app permission to access
| all files.
| out_of_protocol wrote:
| Well, this one is on google. "Full filesystem access" is
| restricted to specific classes of apps like file
| managers, and replacement api is very shitty (have lots
| of restrictions, slower by orders of magnitude)
| trinix912 wrote:
| Anything that just shuffles on the filesystem/folder level
| works for this. Even my Honda Civic's stereo does it. Then
| you have iTunes, which uses playlists, and doesn't work. It
| starts repeating songs before it exhausts the playlist.
| brookst wrote:
| Ah, the old "should a random shuffle repeat songs" debate.
| Haven't thought about that in years.
|
| I'm with you in that I think shuffle should be a single
| list of all songs, played in a random order. But that
| requires maintaining state, detecting additions and
| updating the list, etc.
|
| Years ago, a friend was adamant that shuffle should mean
| picking a random song from the list each time, without
| state, and if that means the same song plays five times in
| a row, well, that's what random means.
| tialaramex wrote:
| I'm comfortable with "random play" meaning we're going to
| pick at random each time but I'm not OK with the idea
| that's "shuffle" shuffle means there were a list of
| things and we shuffled it. Rolling a D20 is random but
| it's not shuffling. Games with a random element
| deliberately (if they're well designed) choose whether to
| have this independence or not in their design.
| hermannj314 wrote:
| A shuffle is type of permutation. There is room to
| disagree on the constraints on the type of permutations
| allowed and how they are made. Nevertheless, I 100% agree
| that sampling with replacement is not a shuffle.
| brookst wrote:
| While I agree with you, as soon as the semantics of
| "random" vs "shuffle" enter the conversation, lay people
| are lost.
|
| To me "shuffle" is a good metaphor because a shuffled
| deck of cards works a specific way (you'd be very
| surprised to draw the same card twice in a row!)
|
| But these things are implemented by programmers who
| sometimes start with implementation ("random") and work
| back to user experience. And, for a specific type of
| technical person, "with replacement" is exactly what
| they'd expect.
| tialaramex wrote:
| If you let _programmers_ do randomness you 're in a world
| of pain.
|
| On the whole programmers given a source of random bytes
| and told to pick any of 227 songs at random using this
| data will take one byte, compute byte % 227 and then be
| _astonished_ that now 29 of the songs are _twice as
| likely as the others_ to be chosen+.
|
| In a class of fifty my guess is you're lucky if one
| person asks whether the random bytes are cheap (and so
| they should just throw away any that aren't < 227)
| showing they know what "random" means and all the rest
| will at least _attempt_ that naive solution even if some
| of them try it out and realise it 's not good enough.
|
| + As a bonus in some languages expect some solutions to
| never pick the first song, or never pick the last song.
| vitus wrote:
| My favorite example of RNG misuse resulting in sampling
| bias is the general approach that looks like `arr.sort(()
| => Math.random() - 0.5)`.
|
| > you're lucky if one person asks whether the random
| bytes are cheap (and so they should just throw away any
| that aren't < 227)
|
| If you can't deal with the 10% overhead from rejection
| sampling (assuming your random bytes are _uniform_ ), I
| guess you could try mushing that entropy back into the
| rest of your bytestream, but yuck.
| tonyhart7 wrote:
| I literally want to do this but for social app, but for
| completely anonim user
|
| Any info on how can I achieve this
| meindnoch wrote:
| You must track the permutation you're stepping through.
|
| E.g. you have 4 items. You shuffle them to get a random
| permutation:
|
| 4 2 1 3
|
| Note: these are _not_ indices, but identifiers. Let 's
| say you go through the first two items:
|
| 4 2 <you're here> 1 3
|
| And two new items arrive. You insert each item into a
| random position among the remaining items. E.g:
|
| 4 2 <you're here> 5 1 6 3
|
| If items are to be deleted, there are two cases: either
| they have already been visited, in which case there's
| nothing to do, or they're in the remaining list, in which
| case you have to delete them from there.
| vitus wrote:
| > I think shuffle should be a single list of all songs,
| played in a random order. But that requires maintaining
| state, detecting additions and updating the list, etc.
|
| You should be able to accomplish this with trivial
| amounts of state (as in, somewhere around 4 ints).
|
| As an example, I'm envisioning something based on
| Fermat's little theorem -- determine some prime `p` at
| least as big as the number of songs you have (N), then to
| determine the next song, use n := a*n mod p for fixed
| choice of 1 < a < p, repeating as necessary as long as n
| > N. This should give you a deterministic permutation of
| the songs. When you get back to the first song you've
| played, you can choose to pick a new `a` for a new
| shuffle, or you can just keep that permutation.
|
| If the list of songs changes, pick new a, p, and update n
| to be the new position of your current song (and update
| your notion of "first song of this permutation").
|
| (Regarding why this works: you want {a} to be a generator
| for the multiplicative group formed by Z/pZ.)
|
| Linear congruential generators have terrible properties
| if you care about the quality of your randomness, but if
| all you're doing is shuffling what order your songs play
| in, they're fine.
| readyplayernull wrote:
| Thanks!! I've been looking for an algo to draw pixel
| positions in a pseudorandom way only once. I didn't know
| a way to do it without storing and shuffling all
| positions. Now, I only need to draw a centered filled
| circle, so there might be a prime number for it, and even
| if the prime only does it for a given amount of points, I
| could switch to other primes until the circle is filled,
| and get an optimal and compressed single-visit scattering
| algo.
| meindnoch wrote:
| Mind you, placing many pixels at coordinates from a
| linear congruential generator will not look random at
| all.
| satvikpendem wrote:
| Have you seen this algorithm for dithering? Reminds me of
| your problem.
|
| https://news.ycombinator.com/item?id=42808889
| readyplayernull wrote:
| Yes, but another requirement is the algo to be very fast,
| and dithering takes way more operations than the proposed
| Fermat PRNG.
| bazzargh wrote:
| this is something you should read
| https://extremelearning.com.au/unreasonable-
| effectiveness-of... (it's effectively the fermat prng
| described, but goes into more depth)
| brookst wrote:
| You may have mathed over my head, but I'm not seeing how
| it avoids playing already-played songs when the list is
| expanded.
|
| Say I have a 20 song list, and after listening to 15 I
| add five more. How does this approach only play the
| remaining 10 songs (5 that were remaining plus 5 new)?
| vitus wrote:
| > Say I have a 20 song list, and after listening to 15 I
| add five more. How does this approach only play the
| remaining 10 songs (5 that were remaining plus 5 new)?
|
| It doesn't. If you add 5 more songs, then the algorithm
| as presented will just treat it as if you're starting a
| new shuffle.
|
| If you genuinely need to keep track of all the songs
| you've already played and/or the songs that you have yet
| to play, then I'm not sure you can do much better than
| keeping a list of the desired play order, randomized via
| Fisher-Yates shuffle each time you want a new shuffled
| ordering -- new songs can be appended to said list and
| shuffled in with the as-yet-unplayed songs.
| Dylan16807 wrote:
| > It doesn't. If you add 5 more songs, then the algorithm
| as presented will just treat it as if you're starting a
| new shuffle.
|
| You probably shouldn't have quoted "detecting additions
| and updating the list, etc." then.
| AlotOfReading wrote:
| One way to do it without retaining additional state would
| be to generate the initial shuffle for N > current song
| list. If the new songs' indices come up, they get played.
| You skip any indices that don't correspond to a valid
| song when it's time to play them.
|
| This has some obvious downsides (e.g. an empty slot that
| was skipped when played and filled by a later insert
| won't be played), but it handles both insertion and
| deletions without replaying songs and you only need to
| store a single integer.
| meindnoch wrote:
| This only works for a fixed list.
| vitus wrote:
| Eh, it depends what you mean by "works". If you mean that
| if you add new songs in the middle of playback, it
| doesn't guarantee that every song is played exactly once
| before any are repeated, sure, but you can't really do
| that unless you're actually tracking all of the songs.
|
| Many approaches that guarantee that property have
| pathological behavior if, say, you add a new song to your
| library after each song that you've played.
| bee_rider wrote:
| I'd suggest the general solution: the machine can keep a
| list of the songs it has played, and bump the oldest
| entries off the list. The list length can be user
| configurable, 0 handles your truly random friend, 1 would
| be enough to just avoid immediate repeats, or it could be
| set to the size of the library. 100 could, I think, give
| you enough time to not notice any repeats I think, right?
| tomovo wrote:
| I'd love to hear more about this. What was the other one you
| found? I wrote Tiny Player for iOS and another one for Mac
| and as more of an "album listener" myself I always struggled
| to keep the shuffle functionality up to other peoples
| expectations.
| readyplayernull wrote:
| That is Lark Player, but it has so many ads that I recently
| uninstalled and kept trying the recommendations in this
| thread. Foobar2000 uses a system modal to let you add
| folders but the SD card is locked by the system on that
| modal even after enabling permissions, other apps can
| access it without issues. Samsung music player can only add
| up to 1000 songs per playlist and there is no easy way to
| split my library. And I just found Musicolet that uses
| playlist and doesn't crash when adding my library, but it
| would be perfect if it could show the randomized order of
| the playlist, so it just jumps on random songs, it would be
| cool to know what's next and before. Winamp (WACUP) on
| desktop does this perfectly.
| Doohickey-d wrote:
| I haven't used it in a while (now using streaming...), But
| Musicolet (https://krosbits.in/musicolet/) should be able to
| do this. Offline-only and lightweight.
| readyplayernull wrote:
| Hey I found it a couple of hours ago, but it doesn't show
| the shuffled order of songs. Anyway it's the best so far.
| asielen wrote:
| Mediamonkey allows me to just go to tracks and hit shuffle
| and then it randomly adds all my tracks to a queue with no
| repeats. You can do it at any level of hierarchy, allmusic,
| playlist, album, artist, genre etc.
|
| Edit: I checked I can also shuffle a folder without adding it
| to the library.
| Aachen wrote:
| Termux: pkg install mplayer cd
| /sdcard/Music find -type f | shuf | head -1 | xargs
| mplayer
|
| (Or whatever command-line player you already have installed.
| I just tested with espeak that audio in Termux works for me
| out of the box and saw someone else mentioning mplayer as
| working for them in Termux:
| https://android.stackexchange.com/a/258228)
|
| - It generates a list of all files in the current directory,
| one per line
|
| - Shuffles the list
|
| - Takes the top entry
|
| - Gives it to mplayer as an argument/parameter
|
| Repeat the last command to play another random song. For
| infinite play: while true; do !!; done
|
| (Where !! substitutes the last command, so run this after the
| find...mplayer line)
|
| You can also stick these lines in a shell script, and I seem
| to remember you can have scripts as icons on your homescreen
| but I'm not super deep into Termux; it just seemed like a
| trivial problem to me, as in, small enough that piping like 3
| commands does what you want for any size library with no
| specialised software needed
| StrangeDoctor wrote:
| Well the 89 is a CAS in disguise most of the time which is
| mentioned in passing in the article.
|
| But, I agree I almost never want the full power of
| Mathematica/sage initially but quickly become annoyed with calc
| apps. The 89 and hp prime//50 have just enough to solve
| anything where I wouldn't rather just use a full programming
| language.
| db48x wrote:
| Same here, except I use an HP48 emulator because TI sucks and
| HP rocks.
| ezst wrote:
| GeoGebra, in fact, embeds xcas and has a touchscreen friendly
| UI.
| the_third_wave wrote:
| HiPER Calc Pro looks like and works like a "physical"
| calculator, I've use it for years to get effect. I also have
| Wabbitemu but hardly ever use it, the former works fine for
| nearly everything.
| Shorel wrote:
| I just installed it, for about 2 Eur.
|
| Thanks for the heads up, I will be testing it for a few
| months, to see if it can replace the TI-89 emulator as my
| main calculator.
|
| Edit: that calculator gives a result of 0 on this test
| acidburnNSA wrote:
| Just tried the TI-89 emulator on android and it says 1e100 + 1
| - 1e100 is 0
| imglorp wrote:
| HP42 on Android checks out
| anonymousiam wrote:
| My favorite Android calculator is RealCalc. I've been using
| it since I got it for PalmOS about 25 years ago.
|
| https://play.google.com/store/apps/details?id=uk.co.nickfin
| e...
| jvdvegt wrote:
| I use it too, but it also computes 0 instead of 1 for:
| e^100 + 1 - e^100
| Shorel wrote:
| Here I got 1 as the answer:
|
| https://imgur.com/a/TH14QZn
| acidburnNSA wrote:
| Aha! So 1e100 doesn't work but 1^100 does. Ok thanks!
| xeonmc wrote:
| 1^100 = 1 though
| ghusbands wrote:
| That's a typo in the response, I believe. The screenshot
| shows 10^100 (10 to the power of 100).
| mgaunard wrote:
| 1e100 is a float.
| jacobp100 wrote:
| I've put a lot of effort into mine, TechniCalc
|
| I've been working on it for what will be a decade later this
| year. It tries to take all the features you had on these
| physical calculators, but present them in a modern way. It
| works on macOS, iOS, and iPad OS
|
| With regards to the article, I wasn't quite as sophisticated as
| that. I do track rationals, exponents, square roots, and
| multiples of pi; then fall back to decimal when needed. This
| part is open source, though!
|
| Marketing page - https://jacobdoescode.com/technicalc
|
| AppStore Link - https://apps.apple.com/gb/app/technicalc-
| calculator/id150496...
|
| Open source components -
| https://github.com/jacobp100/technicalc-core
| sneak wrote:
| I am seriously curious when it became not a violation of the
| principle of least surprise that a calculator app uses the
| network to communicate information from my device (which
| definitionally belongs to me) to the developer.
|
| Where I am standing, that never happened, but that would
| require that a simply staggering number of people be
| classified as unreasonable.
| jacobp100 wrote:
| The only network requests are for currency rates, and
| Sentry crash logs. I don't collect analytics other than
| these crash logs
|
| https://jacobdoescode.com/privacy
| sneak wrote:
| It is the Sentry surveillance to which I refer. The
| crashes on my computer do not belong to you.
| jacobp100 wrote:
| You can't please everyone. Do note these are only sent
| when something goes wrong in the app. To give you an
| indication of how little I collect, for the last 30 days,
| I can see 3,700 app sessions (only includes people who
| opted into Apple's analytics), and 14 reports of
| exceptions within the app. That's fewer than 0.4% of
| users.
| lupire wrote:
| TI-89 doesn't have infinite precision.
|
| Built-in Android calculator does.
|
| They are incomparable. TI-89 has tons of features, but can't
| take a square foot to high accuracy.
| vaporary wrote:
| Can you tell me which emulator you're using? I loved using the
| open source Wabbitemu on previous Android phones, but it seems
| to have been removed from the app store, so I can't install it
| on newer devices :-/
| Shorel wrote:
| https://f-droid.org/en/packages/com.eanema.graph89/
| dgacmu wrote:
| Anyone know of a comparison of the linked paper's algorithm to
| how Gavin Howard's 'bc' CLI calculator does it?
| tialaramex wrote:
| So, 'bc' just has the (big) rationals. Rationals are the
| numbers you could make by taking one integer (say 5 or minus
| sixteen trillion and fifty-one) and dividing it by some
| positive integer (such as three or sixty-two thousand)
|
| If we have a "Big Integer" type which can represent arbitrarily
| huge integers, such 10 to the power 5000, we can use two of
| these to make a Big Rational, and so that's what bc has.
|
| But the rationals aren't enough for all the features on your
| calculator. What's the square root of ten ? How about the
| square root of 40 ? Now, multiply those together. The correct
| answer is 20. Not 20.00000000000000001 but exactly 20.
| dgacmu wrote:
| Ahh, thank you. Yes indeed: bc says: >>>
| sqrt(10) * sqrt(10) 9.99999999999999999994
|
| Android calculator, on the other hand, gets this one right.
| netsharc wrote:
| > (Also I decided to try writing this thread in the style of a
| linkedin influencer lol, sorry about that.)
|
| I hated reading this buzzfeedy style (or apparently LinkedIn-
| style?) moron-vomit.
|
| I shouldn't complain, just ask my nearest LLM to rewrite this
| article^W scribbling to a less obnoxious form of writing..
| Kiro wrote:
| I liked it.
| Minor49er wrote:
| I noticed this too, but I was confused because the calculator
| article was informative and interesting. It's entirely unlike
| the inept fluffy slop that gets posted to LinkedIn
| tonyedgecombe wrote:
| I think it's called broetry although perhaps the sentences are
| a little long for that.
| raincole wrote:
| I really hate when people put cat images and memes in a serious
| article.
|
| Don't get me wrong, the content is good and informative. But I
| just hate the format.
|
| That reminds me when SideFX started putting memes into their
| official tutorial youtube channel. At least this is just a
| webpage and we can scroll through them...
| JDEW wrote:
| Also the "highschool poem"-type writing style is quite jarring
| but forgiven when he acknowledged it at the end of the article.
|
| > Also I decided to try writing this thread in the style of a
| linkedin influencer lol, sorry about that.
| lapcat wrote:
| While we're already breaking the HN guidelines--"Please don't
| complain about tangential annoyances--e.g. article or website
| formats"--let me just say that the scrolljacking on this
| article is awful.
| ChadNauseam wrote:
| I've not intentionally implemented any scrolljacking (I'm
| using the default obsidian template), but I'm curious what
| you mean as I also don't see where the scrolljacking would
| happen. Could you elaborate on the way in which the user
| experience is awful now, so I can improve it?
| rs186 wrote:
| The tone of the article has given away the fact that the
| article is not serious. At least not the way it's presented.
| You want something serious? Go read the pdf.
|
| And I don't mind at all. Without this article, I probably will
| never know what's in the paper and how they iterated. I'll
| likely give up after reading the abstract -- "oh, they solved a
| problem". But this article actually makes much more motivating
| to read the original paper, which I plan to do now.
| ChadNauseam wrote:
| I'm happy to have spread the good word! Note that when you
| read the paper, some implementation details are slightly
| different than my description. For instance, they always
| store the recursive real form of the real part of each
| number, even when the symbolic part perfectly describes it. I
| removed this redundancy to try to simplify it for twitter,
| but I hope it doesn't confuse those who go on to read the
| paper afterwards.
| moffkalast wrote:
| Well the cats hate you right back, how dare you. The whole
| point of the internet is to post cats on it.
| josu wrote:
| The original is a Twitter thread, not a serious article.
| op00to wrote:
| Two cat pictures. 0 memes. Lighten up.
| qwertytyyuu wrote:
| Bah, cats have a place in programming articles, regardless of
| seriousness
| FpUser wrote:
| Cats rule our world. So nothing wrong about it.
| troymc wrote:
| This was not intended to be a serious article, like something
| you'd submit for publication in an ACM journal.
|
| The last sentence is: "(Also I decided to try writing this
| thread in the style of a linkedin influencer lol, sorry about
| that.)"
| move-on-by wrote:
| I enjoyed the article, but it seems Apple has since improved
| their calculator app slightly. The first example is giving me the
| correct result today. However, the second example with the
| "Underflow" result is still occurring.
| yreg wrote:
| I remember hearing stories that for a time there was no
| engineer inside Apple responsible for the iOS Calculator.
|
| Now it seems to be revived as there were some updates to it,
| but those also removed one of my favourite features -> tapping
| equals button no longer repeats the last operation.
| basicoperation wrote:
| They fortunately fixed the repeating feature in iOS 18.3.
| Though it does seem a bit ridiculous that something like this
| is tied to the entire OS version.
| yreg wrote:
| Oh, nice - thanks! So it was a bug afterall.
| NlightNFotis wrote:
| I've just tried the first example on iOS 18.3.1 and it
| absolutely reproduces perfectly for me.
| move-on-by wrote:
| Oh no- I stand corrected. I tried it again and you are right.
| I had just woken up when I did my initial test and must have
| typoed something. I can no longer edit or delete my original
| comment :(
| HappyPanacea wrote:
| > It's too slow.
|
| > 1 is not equal to 1 - e^(-e^1000). But for Richardson and
| Fitch's algorithm to detect that, it would require more steps
| than there are atoms in the universe.
|
| > They needed something faster.
|
| I'm disappointed after this paragraph I expected a better
| algorithm and instead they decided to give up. Fredrik Johansson
| in his paper "Calcium: computing in exact real and complex
| fields" gives a partial algorithm for the problem and writes
| "Algorithm 2 is inspired by Richardson's algorithm, but
| incomplete: it will find logarithmic and exponential relations,
| but only if the extension tower is flattened (in other words, we
| must avoid extensions such as e^log(z) or [?]z^2), and it does
| not handle all algebraic functions. Much like the Risch
| algorithm, Richardson's algorithm has apparently never been
| implemented fully. We presume that Mathematica and Maple use
| similar heuristics to ours, but the details are not documented
| [6], and we do not know to what extent True/False answers are
| backed up by a rigorous certification in those system".
| gravitronic wrote:
| years ago the daily wtf had a challenge for writing the worst
| calculator app. my submission maintained calculation state by
| emitting it's own source code, recompiling and running the new
| executable.
| LordShredda wrote:
| People call that a JIT compiler nowadays (?)
| tasty_freeze wrote:
| I first learned to program on a Wang 2200 computer with 8KB of
| RAM, back in 1978. One of the math teachers stayed an hour late
| most days to allow us nerds to come in an use the two
| computers. There were more people than computers, so often
| you'd only get 10 or 15 minutes of time.
|
| Anyway, I wrote a program where you could enter an equation and
| it would draw an ASCII graph of the curve. I didn't know how to
| parse expressions and even if I had I knew it would be slow.
| The machine had a cassette tape under computer control for
| storing and loading programs. What I did was to take the
| expression typed by the user and convert each one into its
| tokenized form and write it out to tape. The program would then
| load that just created overlay which contained something like
| "1000 DEF FNY(X)=X^2-5" and a FOR loop would sweep X over the
| designated range, and have "LET Y=FNY(X)" to evaluate the
| expression for me.
|
| As a result, after entering the equation, it would take about
| five seconds to write out the overlay, rewind a couple blocks,
| and load the overlay before it would start to plot. But once it
| started it went pretty fast.
| smarks wrote:
| Hey! A fellow Wang 2200 veteran!
| gravitronic wrote:
| That's a really cool and simple solution to a difficult
| problem!! I love it!
| 1970-01-01 wrote:
| I removed telemetry on my Win10 system and now calc.exe crashes
| on basic calculations. I've reported this but nobody cares
| because the next step in troubleshooting is to reinstall Windows.
| So if telemetry fails, calc.exe will silently explode. Therefore
| no, anyone cannot make it.
|
| Won't fix: https://github.com/microsoft/calculator/issues/148
| cowsandmilk wrote:
| Based on the thread, you can build it from the source code and
| telemetry won't be enabled...
| 1970-01-01 wrote:
| I just use the Win7 binary. Calc.exe is the definition of
| something that really doesn't need to change.
| noinsight wrote:
| How do you make the Win7 binary run? Last I tried it
| doesn't run if you just have the .exe?
| 1970-01-01 wrote:
| https://win7games.com/#calc
| Aachen wrote:
| Windows XP's mspaint.exe stopped working at some point :(.
| I was also in the team "simple tool worked as I want it to"
| for as long as that lasted. (I don't use Windows anymore,
| not for only this reason obviously but still, I don't seem
| to have these problems anymore where you can't make things
| work a certain way.)
| trinix912 wrote:
| > Won't fix: https://github.com/microsoft/calculator/issues/148
|
| I don't see how one can expect them to take a report worded
| this way seriously. Perhaps if they actually reported the crash
| without the tantrum the team would fix it.
| rvba wrote:
| So they send telemetry that shows what people are calculating.
|
| Does it mean that there are some "dangerous" numbers that can
| be used to flag someone?
| 1970-01-01 wrote:
| I did begin poking at the crash for security issues but gave
| up after 10 minutes
| Aachen wrote:
| I don't know if you've already heard of illegal numbers;
| otherwise, you're one of today's lucky ten thousand!
|
| https://en.wikipedia.org/wiki/Illegal_number
| jll29 wrote:
| Good read, thanks.
| schneems wrote:
| This is interesting.
|
| One of the first ideas I had for an app was a calculator that
| represented digits like shown in the article but allowed you to
| write them with variables and toggle between symbolic and actual
| responses.
|
| A use case would be: in a spreadsheet like interface you could
| verify if the operations produced the final equation you were
| modeling in order to help validate if the number was correct or
| not. I had a TI-89 that could do something close and even in 2006
| that was not exactly brand new tech. I figured surely some open
| source library available on the desktop must get me close. I was
| wildly wrong. I stuck with programming but abandoned the
| calculator idea. Even nearly 20 years later, such a task doesn't
| seem that much easier to me.
| pkaye wrote:
| Isn't what you are asking for a CAS?
| AlotOfReading wrote:
| That's a CAS, as mentioned. There are plenty of open source
| libraries available, but one that specifically implements the
| algorithms discussed in this article is flintlib. Here's an
| example from their docs showing exactly what you want:
| https://flintlib.org/doc/examples_calcium.html#examples-calc...
| schneems wrote:
| Thanks!
| 11235813213455 wrote:
| recursive descent parser, normally any decent developer can do
| that, my version: https://caub.github.io/misc/calculator
| Aardwolf wrote:
| "-2 ** 3 SyntaxError: unparenthesized unary expression can't
| appear on the left-hand side of '*' "
|
| That's actually a great error, I have made the mistake of
| expecting "-2 ** 2" would output 4 instead of -4 before.
| pedrosorio wrote:
| ^ fyi, this comment reveals you didn't RTFA
| rustybolt wrote:
| Nice story. An even more powerful way to express numbers is as a
| continued fraction
| (https://en.wikipedia.org/wiki/Continued_fraction). You can
| express both real and rational numbers efficiently using a
| continued fraction representation.
|
| As a fun fact, I have a not-that-old math textbook (from a famous
| number theorist) that says that it is most likely that algorithms
| for adding/multiplying continued fractions do not exist. Then in
| 1972 Bill Gosper came along and proved that (in his own words)
| "Continued fractions are not only perfectly amenable to
| arithmetic, they are amenable to perfect arithmetic.", see
| https://perl.plover.com/yak/cftalk/INFO/gosper.txt.
|
| I have been working on a Python library called reals
| (https://github.com/rubenvannieuwpoort/reals). The idea is that
| you should be able to use it as a drop-in replacement for the
| Decimal or Fraction type, and it should "just work" (it's very
| much a work-in-progress, though). It works by using the
| techniques described by Bill Gosper to manipulate continued
| fractions. I ran into the problems described on this page, and a
| lot more. Fun times.
| naniwaduni wrote:
| > You can express both real and rational numbers efficiently
| using a continued fraction representation.
|
| No, all finite continued fractions express a rational number
| (for... obvious reasons), which is honestly kind of a
| disappointment, since arbitrary sequences of integers can, as a
| matter of principle, represent arbitrary computable numbers if
| you want them to. They're powerful than finite positional
| representations, but fundamentally equivalent to simple
| fractions.
|
| They are occasionally convenient for certain problem structures
| but, as I'm sure you've already discovered, somewhat less
| convenient for a wide range of _common_ problems.
| layer8 wrote:
| The linked paper by Bill Gosper is about potentially infinite
| continued fractions with potentially irrational symbolic
| terms.
| rustybolt wrote:
| > No, all finite continued fractions express a rational
| number
|
| Any real number x has an infinite continued fraction
| representation. By efficient I mean that the information of
| the continued fraction coefficients is an efficient way to
| compute rational upper and lower bounds that approximate x
| well (they are the best rational approximations to x).
|
| > They are occasionally convenient for certain problem
| structures but, as I'm sure you've already discovered,
| somewhat less convenient for a wide range of common problems.
|
| I'm curious what you mean exactly. I've found them to be very
| convenient for evaluating arithmetic expressions (involving
| both rational and irrational numbers) to fairly high
| accuracy. They are not the most efficient solution for this,
| but their simplicity and not having to do error analysis is
| far better than any other purely numerical system.
|
| > fundamentally equivalent to simple fractions.
|
| This feels like it is a bit too reductionist. I can come up
| with a lot of example, but it's quite hard to find the best
| rational approximations of a number with just fractions,
| while it's trivial with continued fractions. Likewise, a
| number like the golden ratio, e, or any algebraic number has
| a simple description in terms of continued fractions, while
| this is certainly not the case for normal fractions.
|
| That continued fractions can be easily converted to normal
| fractions and vice versa, is a strength of continued
| fractions, not a weakness.
| SkiFire13 wrote:
| > finite
|
| That's the issue, no? If you go infinite you can then express
| any real number. You can then actually represent all those
| whose sequence is equivalent to a computable function.
| pclmulqdq wrote:
| You are describing something that is practically more like
| a computer algebra system than a number system. To go
| infinite without infinite storage, you need to store the
| information required to compute the trailing digits of the
| number. That is possible with things like pi, which have
| recursive formulas to compute, but it's not easy for
| arbitrary numbers.
| dan-robertson wrote:
| How do you work out an answer for x - y when eg x = sqrt(2) and
| y = sqrt(2) - epsilon for arbitrarily small epsilon? How do you
| differentiate that from x - x?
| rustybolt wrote:
| In a purely numerical setting, you can only distinguish these
| two cases when you evaluate the expression with enough
| accuracy. This may feel like a weakness, but if you think
| about this it is a much more "honest" way of handling
| inaccuracy than just rounding like you would do with floating
| point arithmetic.
|
| A good way to think about the framework, is that for any
| expression you can compute a rational lower and upper bound
| for the "true" real solution. With enough computation you can
| get them arbitrarily close, but when an intermediate result
| is not rational, you will never be able to compute the true
| solution (even if it happens to be rational; a good example
| is that for sqrt(2) * sqrt(2) you will only be able to get a
| solution of the form 2 +- [?] for some arbitrarily small
| [?]).
| zozbot234 wrote:
| > you will only be able to get a solution of the form 2 +-
| [?] for some arbitrarily small [?]
|
| The problem with that from a UX perspective is that you
| won't even get to write out the first digit of the solution
| because you can never decide whether it should be
| 1.999...999something (which truncates to 1.99) or
| 2.000...000something (which truncates to 2.00). This is a
| well-known peculiarity of "exact" real computation and is
| basically one especially relevant case of the 'Table-
| maker's dilemma'
| https://en.wikipedia.org/wiki/Rounding#Table-
| maker%27s_dilem...
| LPisGood wrote:
| Continued fractions are very cool. I saw in a CTF competition
| once a question about breaking an RSA variant that relied on
| the fact that a certain ratio was a term in sequence of
| continued fraction convergents.
|
| Naturally the person pursing a PhD in number theory (whom I
| recruited to our team for specifically this reason) was unable
| to solve the problem and we finished in third place.
| jwilk wrote:
| Sounds a bit like
| https://en.wikipedia.org/wiki/Wiener%27s_attack.
|
| (It's not a good article when it comes to the attack details,
| unfortunately.)
| SloopJon wrote:
| I played around with the calculator source code from the Android
| Open Source Project after a previous submission[1]. I think
| Google moved it from AOSP to the Google Play Services several
| years ago, but the old source is still available.
|
| It does solve some real problems that I'd love to have available
| in a library. The discussion on the previous article links to
| some libraries, but my recollection is that the calculator code
| is more accessible to an innumerate person like myself.
|
| Edit: the previous article under discussion doesn't seem to be
| available, but it's on archive.org[2].
|
| [1] https://news.ycombinator.com/item?id=24700705
|
| [2]
| https://web.archive.org/web/20250126130328/https://blog.acol...
| yonran wrote:
| > I think Google moved it from AOSP to the Google Play Services
| several years ago, but the old source is still available.
|
| For the curious, here is the source of ExactCalculator from the
| commit before all files were deleted: https://android.googlesou
| rce.com/platform/packages/apps/Exac..., and here is the
| dependency CR.java
| https://android.googlesource.com/platform/external/crcalc/+/...
| ksec wrote:
| So did they fix the iOS Calculator bug?
|
| On another note. Since Calculator is so complex are there any
| open source cross platform library that makes it easier to
| implement?
| perlgeek wrote:
| I imagine you could do most or all of this with yacas, which is
| actually a computer algebra system (GPL).
| troymc wrote:
| From the linked post: 'A "computer algebra system" would have
| accomplished a similar goal, but been much slower and much
| more complicated'
| Kiro wrote:
| He was not working on the iOS Calculator.
| mg wrote:
| To make any type of app really good is super hard.
|
| I have yet to see a good to-do list tool.
|
| I'm not kidding. I tried TickTick, Notion, Workflowy ...
| everything I tried so far feels cumbersome compared to how I
| would like to handle my To-Do list. The way you create, edit,
| browse, drag+drop items is not as all as fluid as I imagine it.
|
| So if anyone knows a good To-Do list software (must be web based,
| so I can use it anywhere without installing something) - let me
| know!
| solumunus wrote:
| I find Trello adequate.
| mg wrote:
| One issue I have with Trello is that it has multiple types of
| items. And that it is not recursive.
|
| When I create an item "Supermarket" and then an item "Bread",
| I cannot drag and drop the item "Bread" into "Supermarket".
| But that is how I think. I have a lot of "items" and each
| item can contain other "items". I don't want any other type
| of object.
|
| Another problem is that I cannot customize the layout. I
| can't remove every icon from the items in the list. I only
| want to see the item names, no other info like the icon that
| shows that there is a description or anything. But Trello
| seems to not support that.
| erikerikson wrote:
| I use Google's Keep but you may need to make your own
| jaredhallen wrote:
| I agree that Keep is pretty good. I switched over to Carnet
| when I setup my nextcloud. It's OK, but not as good as Keep.
| philipwhiuk wrote:
| To-Do List is an infinite product category.
|
| They are extremely personal and any unwanted features end up as
| friction.
|
| You'll never find a perfect Todo app because it will have an
| audience of 1 so wouldn't be made.
|
| Other examples of Todo apps:
|
| Things, 2Do, Todoist, OmniFocus, Due, Reminders (Apple), Clear,
| GoodTask, Notes, Google Keep
|
| The list is literally neverending,
| mg wrote:
| Why does a to-do list have to have any features by default?
| It could be a blank screen with a "settings" sign in the
| upper right, where you can enable just the features you need.
|
| If I don't find such a software, I will write it myself. I
| actually already started:
|
| https://x.com/marekgibney/status/1844077244903571549
|
| I am developing it on the side, while I try to get by with
| existing solutions.
| lupire wrote:
| Not every "feature" is a checkbox. Many features are about
| how the UI integrates everything and changes over time.
|
| So your "settings" asking the user to design their own app!
|
| That's the developer's job!
| mg wrote:
| What would be an example of a feature that can not be
| enabled via a checkbox?
| efitz wrote:
| Remind me in X number of days.
| xboxnolifes wrote:
| The setting to use checkboxes.
| pizzafeelsright wrote:
| Any.do did me well until I adopted a new method of stacking
| tasks into a routine.
|
| The hard part is altering the routine.
| mg wrote:
| Just tried it. Way too much stuff on the screen for my
| liking. Plus it seems to be not recursive.
|
| Similar to my thoughts about Trello:
|
| https://news.ycombinator.com/item?id=43068867
| jchw wrote:
| I would love to have a To-Do app that is fluid for both one-off
| tasks and periodic checklists (daily/weekly/monthly/etc.) Most
| importantly, I want it to yell at me to actually do it. I was
| pretty surprised that basically nothing seems to fit the bill
| and even what existing "GTD" type apps _could_ do felt
| cumbersome and limited.
| DanielDe wrote:
| I'm one of the creators of Godspeed, which is a fast, 100%
| keyboard oriented to-do app (though we do support drag and drop
| as well!). And we've got a web app!
|
| https://godspeedapp.com/
| mg wrote:
| Just tried it, and this is very much the opposite of what I
| am looking for.
|
| What I would like is a very minimal layout. Basically with
| nothing on the screen. And I want to be able to organize my
| world by dragging, dropping, swiping recursive items.
| russellbeattie wrote:
| It seems like you're looking for an outliner? Workflowy might
| fit your needs: https://workflowy.com/
|
| Like others have said, the perfect to-do list is impossible
| because each person wants wildly different functionality.
|
| My dream to-do list has minimal interaction, with the details
| handled like I have my own personal secretary. All I'd do is
| verbally say something like "remind me to do laundry later" and
| it would do the rest: Categorizing, organizing, prioritizing,
| scheduling and adding sub-tasks as needed.
|
| I love the idea of automatic sub-tasks created at level which
| helps with your particular procrastination level. For example
| "do laundry" would add in "gather clothes, bring to laundry
| room, separate colors, add to washer, set timer, add to dryer,
| set timer, get clothes, fold clothes, put away, reschedule in a
| week (but hide until then). Maybe it's even add in Pomodoro
| timers to help.
|
| LLMs with reasoning might get us there soon - we've been
| waiting for Knowledge Navigator like assistants for years.
| based2 wrote:
| https://github.com/based2/KB/blob/main/math/aaa.md#calculato...
| red_admiral wrote:
| There's a point at which you're really building a computer
| algebra system.
|
| Or you can do what the Windows 11 calculator does and not even
| get 1+2*3 right.
| tasty_freeze wrote:
| I'm on windows 11. I just did it and it replied "7". I
| subtracted 7 to see if there was some epsilon error but it
| reported "0". What do you experience?
| thomaspark wrote:
| I solved this by making a calculator that rounds to the nearest
| 1/16. Tiny app for Americans doing DIY work around the house:
|
| https://thomaspark.co/projects/calc-16/
| adilcanq wrote:
| lowkey this is why ieee 754 floating point is both a blessing and
| a curse, like yeah it's fast n standardized but also introduces
| unavoidable precision loss, esp w iterative computations where
| rounding errors stack up in unpredictable ways. ppl act like
| increasing precision bits solves everything. but u just push the
| problem further down, still dealing w truncation, cancellation,
| etc. (and edge cases where numerical stability breaks down.)
|
| ... and this is why interval arithmetic and arbitrary precision
| methods exist, so it gives guaranteed bounds on error instead of
| just hoping fp rounding doesn't mess things up too bad. but obv
| those come w their own overhead: interval methods can be overly
| conservative, which leads to unnecessary precision loss, and
| arbitrary precision is computationally expensive, scaling non-
| linearly w operand size.
|
| wonder if hybrid approaches could be the move, like symbolic
| preprocessing to maintain exact forms where possible, then
| constrained numerical evaluation only when necessary. could
| optimize tradeoffs dynamically. so we'd keep things efficient
| while minimizing precision loss in critical operations. esp
| useful in contexts where precision requirements shift in real
| time. might even be interesting to explore adaptive precision
| techniques (where computations start at lower precision but
| refine iteratively based on error estimates).
| GistNoesis wrote:
| That's just a single number to calculate.
|
| The real fun begins when you do geometry.
|
| Find a representation of finite memory to represent points, which
| allows exact addition, multiplication and rotation between them,
| (with all the nice standard math property like associativity and
| commutativity).
|
| For example your representation should be able to take a 2d point
| A, aka two coordinates, and rotate it around the origin by an
| angle theta to obtain the point B. Take the original point and
| rotate it by pi + theta, then reflect it around the origin to
| obtain the point C. Now answer the question whether B is
| coincident with C.
| wiz21c wrote:
| I use qalculate, it behaves well enough for my needs.
|
| https://qalculate.github.io/
| librasteve wrote:
| I just tried this in raku App::Crag...
|
| crag 'say (10*100) + 1 - (10*100)' #1
|
| Raku uses Rats by default (Rational numbers) unless you ask for
| floating point.
| mynegation wrote:
| As soon as I read the title, I chuckled, because coming from the
| computational mathematics background I already knew what it
| roughly is going to be about. IEEE 754 is like democracy in a
| sense that it is the worst, except for all the others.
| Immediately when I saw the example I thought: it is either going
| to be either a Kahan summation or full-scale computer algebra
| system. It turned out to be some subset of the latter and I have
| to admit I have never heard of Recursive Real Arithmetic (I knew
| of Real Analysis though).
|
| If anything that was a great insight about one of my early C++
| heroes, and what they did in their professional life outside of
| the things they are known for. But most importantly it was a
| reminder how deep seemingly simple things can be.
| titzer wrote:
| IEEE 754 is what you get if you started with the idea of sign,
| exponent, and fraction and made the most efficient hardware
| implementation of it possible. It's not "beautiful", but it
| falls out pretty straightforwardly from those starting
| assumptions, even the seemingly weirder parts like -0,
| subnormals and all the rounding modes. It was not really
| democratically designed, but done by numerical computing
| experts coupled with hardware design experts. Every
| "simplified" implementation of floating point that has appeared
| (e.g. auto-FTZ mode in vector units) has eventually been
| dragged kicking and screaming back to the IEEE standard.
| AlotOfReading wrote:
| Another way to see it is that floating point is the logical
| extension of fixed point math to log space to deal with
| numbers across a large orders of magnitude. I don't know if
| "beautiful" is exactly the right word, but it's an incredibly
| solid bit of engineering.
| dan-robertson wrote:
| I feel like your description comes across as more negative on
| the design of IEEE-754 floats than you intend. Is there
| something else you think would have been better? Maybe I'm
| misreading it.
|
| Maybe the hardware focus can be blamed for the large
| exponents and small mantissas.
|
| The reasonable only non-IEEE things that comes to mind for me
| are:
|
| - bfloat16 which just works with the most significant half of
| a float32.
|
| - log8 which is almost all exponent.
|
| I guess in both cases they are about getting more out of
| available memory bandwidth and the main operation is f32 + x
| * y -> f32 (ie multiply and accumulate into f32 result).
|
| Maybe they will be (or already are) incorporated into IEEE
| standards though
| tbrownaw wrote:
| > _what you get if you started with the idea of sign,
| exponent, and fraction and made the most efficient hardware
| implementation of it possible. It 's not "beautiful", but it
| falls out pretty straightforwardly from those starting
| assumptions_
|
| This implies a strange way of defining what "beautiful" means
| in this context.
| bigstrat2003 wrote:
| > IEEE 754 is like democracy in a sense that it is the worst,
| except for all the others.
|
| I can't see what would be worse. The entire raison d'etre for
| computers is to give _accurate_ results. Introducing a math
| system which is inherently inaccurate to computers cuts against
| the whole reason they exist! Literally any other math solution
| seems like it would be better, so long as it produces accurate
| results.
| aoeusnth1 wrote:
| Sometimes you need a number system which is 1. approximate 2.
| compact and fast 3. high dynamic range
|
| You're going to have a hard time doing better than floats
| with those constraints.
| raverbashing wrote:
| There's no "accurate results" most of the time
|
| You can only have a result that's exact enough in your
| desired precision
| meindnoch wrote:
| Define "accurate"!
| recursive wrote:
| > so long as it produces accurate results
|
| That's doing a lot of work. IEE-754 does very in terms of
| error vs representation size.
|
| What system has accurate results? I don't know any number
| system at all in usage that 1) represents numbers with a
| fixed size 2) Can represent 1/n accurately for reasonable
| integers 3) can do exponents accurately
| foxglacier wrote:
| It's ideal for engineering calculations which is a common use
| of computers. There, nobody cares if 1-1=0 exactly or not
| because you could never have measured those values exactly in
| the first place. Single precision is good enough for just
| about any real-world measurement or result while double
| precision is good for intermediate results without losing
| accuracy that's visible in the single precision input/output
| as long as you're not using a numerically unstable algorithm.
| dan-robertson wrote:
| Electronic computers were created to be faster and cheaper
| than a pool of human computers (who may have had slide rules
| or mechanical adding machines). Human computers were
| basically doing decimal floating point with limited
| precision.
| pclmulqdq wrote:
| IEEE 754 is what you get when you want numbers to have huge
| dynamic range, equal precision across the range, and fixed bit
| width. It balances speed and accuracy, and produces a result
| that is very close to the expected result 99.9999999% of the
| time. A competent numerical analyst can take something you want
| to do on paper and build a sequence of operations in floating
| point that compute that result almost exactly.
|
| I don't think anyone who worked on IEEE 754 (and certainly
| nobody who currently works on it) contemplated calculators as
| an application, because a calculator is solving a fundamentally
| different problem. In a calculator, you can spend 10-100 ms
| doing _one operation_ and people won 't mind. In the
| applications for which IEEE 754 is made, you are expecting to
| do billions or trillions of operations per second.
| buescher wrote:
| William Kahan worked on both IEEE 754 and HP calculators. The
| speed gap between something like an 8087 and a calculator was
| not that big back then, either.
| 8n4vidtmkvmk wrote:
| > equal precision across the range
|
| What? Pretty sure there's more precision in [0-1] than there
| is in really big numbers.
| pclmulqdq wrote:
| Precision in numerics is usually considered in relative
| terms (eg significant figures). Every floating point number
| has an equal number of bits of precision. It is true,
| though, that half of the floats are between -1 and 1. That
| is because precision is equal across the range.
| adamddev1 wrote:
| The way this article talks about using "recursive real
| arithmetic" (RRA) reminds me of an excellent discussion with
| Conal Elliot on the Type Theory For All podcast. He talked about
| moving from representing things discretely to representing things
| continually (and therefore more accurately). For instance,
| before, people represented fonts as blocks of pixels, (discrete.)
| They were rough approximations of what the font really was. But
| then they started to be recognized as lines/vectors (continual),
| no matter the size, they represented exactly what a font was.
|
| Conal gave a beautiful case for how comp sci should be about
| pursuing truth like that, and not just learning the latest
| commercial tool. I see the same dogged pursuit of true, accurate
| representation in this beatiful story.
|
| - https://www.typetheoryforall.com/episodes/the-lost-elegance-...
|
| - https://www.typetheoryforall.com/episodes/denotational-desig...
| ChadNauseam wrote:
| Thanks, that's a lovely analogy and I'm excited to listen to
| that podcast.
|
| I think the general idea of converting things from discrete and
| implementation-motivated representations to higher-level
| abstract descriptions (bitmaps to vectors, in your example) is
| great. It's actually something I'm very interested in, since
| the higher-level representations are usually much easier to do
| interesting transformations to. (Another example is going from
| meshes to SDFs for 3D models.)
|
| You might get a kick out of the "responsive pixel art" HN post
| from 2015 which implements this idea in a unique way:
| https://news.ycombinator.com/item?id=11253649
| t43562 wrote:
| I doubt that most people using the calc app expect it to handle
| such situations. It's nice that it does of course but IMO it
| misses the point that the inputs to a lot of real world
| calculations are inaccurate to start with.
|
| i.e it's more likely that I've made a few mm mistake when
| measuring the radius of my table than that I'm not using an
| precise enough version of Pi. The area of the table will have
| more error because one is squaring the radius, obviously.
|
| It would be interesting to have a calculator that let you add in
| your estimated measurement error (or made a few reasonable
| guesses about it for you) and told you the error in your result
| e.g. the standard deviation.
|
| I sometimes want to buy stuff at a hardware shop and I think :
| "how much paint do I need to buy?" I haven't planned so I'm
| thinking "it's about 4m by 5m...I think?" I try to do a couple of
| calculations with worst case numbers so I at least get enough
| paint and save another trip to the shop but not comically too
| much so that I have a tin of it for the next 5 years.
|
| I remember having to estimate error in results that were
| calculated from measured values for physics 101 and it was a
| pain.
| grandempire wrote:
| This is a crazy take to me. Most people don't care that a
| calculator gives them a correct answer? It's just an estimator?
|
| Why would we not expect it to work when we know how to build
| ones that do, and people use it as a replacement for math on
| paper?
| staplung wrote:
| All the calculators that I just tried for the article's
| expression give the wrong answer (HP Prime, TI-36X Pro, some
| casio thing). Even google's own online calculator gives the wrong
| answer, which is mildly ironic.
| [https://www.google.com/search?q=1e101%2B1-1e101&oq=1e101%2B1]
|
| I played around with the macOS calculator and discovered that the
| dividing line seems to be at 1e33. I.e. 1e33+1-1e33 gives the
| correct answer of 1 but 1e34+1-1e34 gives 0. Not sure what to
| make of that.
| Const-me wrote:
| > the dividing line seems to be at 1e33.. Not sure what to make
| of that
|
| That's not too bad. They are probably using hand-rolled FP128
| format for their numbers. If they were using hardware-provided
| FP64 arithmetic, the threshold would have been 2^53 [?] 9E+15:
| https://en.wikipedia.org/wiki/Double-precision_floating-poin...
| Const-me wrote:
| Due to backwards compatibility modern PC CPUs have some
| mathematical constants in hardware, one of them Pi
| https://www.felixcloutier.com/x86/fld1:fldl2t:fldl2e:fldpi:f...
| Moreover, that FLDPI instruction delivers 80 bits of precision,
| i.e. more precise than FP64.
|
| That's pretty much useless in modern world because the whole x87
| FPU is deprecated. Modern compilers are generating SSE1 and SSE2
| instructions for floating-point arithmetic, instead of x87.
| NooneAtAll3 wrote:
| > Showing 0.0000000000000 on the screen, when the answer is
| exactly 0, would be a horrible user experience.
|
| > They realized that it's not the end of the world if they show
| "0.000000..." in a case where the answer is exactly 0
|
| so... devs self-made a requirement, got into trouble (complexity)
| - removed the requirement, trouble didn't go anywhere
|
| just keep saying "it's a win" and you'll be winning, I guess
| nightpool wrote:
| No? They made a goal to show 0.0000 in as few places as
| possible, and they got as close to it as they could without
| compromising their other requirements.
| HarHarVeryFunny wrote:
| Interesting article, and kudos to Boehm for going the extra
| mile(s), but it seems like overkill to me.
|
| I wouldn't expect, or use, a calculator for any calculation
| requiring more accuracy than the number of digits it can display.
| I'm OK with with iPhone's 10^100 + 1 = 1e100.
|
| If I really needed something better, I'd try Wolfram Alpha.
| kevinpacheco wrote:
| The NYC subway fare is $2.90. I was using PCalc on iOS to step
| through remaining MetroCard values per swipe and discovered that
| AC, 8.7, m+, 2.9, m-, m-, m- evaluates to -8.881784197E-16
| instead of zero. This doesn't happen when using Apple's
| calculator. I wrote to the developer and he replied, "Apple has
| now got their own private maths library which isn't available to
| developers, which they're using in their own calculator. What I
| need to do is replace the Apple libraries with something else -
| that's on my list!"
| 6SixTy wrote:
| Sounds like he's just using stock math functions. Both
| Javascript and Python act the same way when you save the result
| immediately after subtracting two numbers multiple times,
| rather than just 8.7 - (2.9*3).
| MatthiasWandel wrote:
| I wrote the calculator for the original blackberry. Floating
| point won't do. I implemented decimal based floating point
| functions to avoid these rounding problems. This sounds harder
| than it was, basically, the "exponent" part wasn't how many
| bits to shift, but what power of two to divide by, so that 0.1,
| 0.001 etc can be represented exactly. Not sure if I had two or
| three digits of precision beyond whats on the display. 1 digit
| is pretty standard for 5 function calculators, scientific ones
| typically have two. It was only a 5 function calculator, so not
| that hard, plus there was no floating point library by default
| so doing any floating point really ballooned the size of an app
| with the floating point library.
| donatj wrote:
| Was given the task to build a simple calculator app as a project
| for a Java class I took in college.
|
| No parens or anything like that, nothing nearly so fancy. Classic
| desk calculator where you set the infix operation to apply to the
| previous value, followed by the second value of the operation.
|
| It was frankly an unexpected challenge. There's a lot more to it
| than meets the eye.
|
| I only got as far as rational numbers though. PI accurate to the
| 8 digit display was good enough for me.
|
| Honestly though, I think it was a great exercise for students,
| showing how seemingly simple tasks can actually be more complex
| than they seem. I'm still here thinking about it some twenty
| years later.
| joelburget wrote:
| I wrote an OCaml implementation of this paper a few years ago,
| which I've now extracted into its own
| [repo](https://github.com/joelburget/constructive-
| reals/blob/main/C...)
|
| The link in the paper to their Java implementation is now broken:
| does anyone have a current link?
| pclmulqdq wrote:
| At some point, when I get a spare 5 years (and/or if people start
| paying for software again), I will start to work on a calculator
| application. Number system wrangling is quite fun and
| challenging, and I am hoping to incorporate units as a first-
| class citizen.
| ShaggyHotDog wrote:
| Saw the thread on Twitter. Kudos to the author for going in so
| much detail!
| chaboud wrote:
| There's a pleasantly elegant "hey, we've solved the practical
| functional complement to this category of problems over here, so
| let's just split the general actual user problem structurally"
| vibe to this journey.
|
| It often pays off to revisit what the actual "why" is behind the
| work that you're doing, and this story is a delightful example.
|
| I wrote an arbitrary precision arithmetic C++ library back in the
| 90's. We used it to compute key pairs for our then new elliptic-
| curve based software authentication/authorization system. I think
| the full cracks of the software were available in less than two
| weeks, but it was definitely a fun aside and _waaaay_ too strong
| of a solution to a specific problem. I was young and stupid...
| now I'm old and stupid, so I'd just find an existing tool chain
| to solve the problem.
| mgaunard wrote:
| Could have just used an off-the-shelf CAS.
| grandempire wrote:
| The point of the article is to teach you how calculators work.
| Not find a piece of software to unblock you.
|
| You may well find yourself in the field of computing having to
| compute something!
| jedberg wrote:
| I thought this was going to be about how Apple completely
| destroyed the calculator on iOS with the latest update.
|
| Now it does the running ticker tape thing, which means you can't
| use the AC button to quickly start over, because there is no AC
| button anymore!
|
| I know it's supposed to be easier/better for the user, but they
| didn't even give me a way to go back to the old behavior.
| shutupnerd0000 wrote:
| Why does the author insist on using a dick bar? With the "contact
| me" portion, it takes up 30% of my screen on an iPhone SE.
| Aachen wrote:
| A what?
|
| I'm also reading this on an sPhone but don't remember seeing
| anything that looked like, well... what you said
| ChadNauseam wrote:
| There should have been an "x" on the right of the "contact me"
| portion that you could click to make it go away. Sounds like it
| didn't show up for you, so sorry about that. Unfortunately I
| don't have an iPhone SE to test against and the "x" does seem
| to show up on the iPhone SE screen-size simulator in Chrome.
| This means I don't know how to reproduce the issue and probably
| won't be able to resolve it without removing the "contact me"
| page entirely, which I'm not willing to do right now.
| Synaesthesia wrote:
| Really interesting article. I noticed that my Android calculator
| app could display irrational numbers like PI to an impressive
| amount of digits, if I hold it sideways.
| daitangio wrote:
| As far as I know, windows calculator have a similar approach. It
| use rational, and switch to Taylor expansion to try to avoid
| cancellation errors. Microsoft open sourced it some times ago on
| GitHub
| gweinberg wrote:
| At the risk of coming across as being a spoilsport, I think when
| someone says "anyone can write a calculator app", they just mean
| an app that simulates a pocket calculator (which is indeed pretty
| easy) as opposed to one which always gives precisely the right
| answer (which is indeed impossible). Also, you can avoid the most
| embarrassing errors just by rearranging the terms to do
| cancellation where possible, e.g. sqrt(2) * 3 * sqrt(2) is
| absolutely precisely 6, not 6 within some degree of
| approximation.
| grandempire wrote:
| Pocket calculators are not using 32 bit floating point math.
| nabaraz wrote:
| Re: (10^100)+1-(10^100)
|
| i) Answer is 0 if you cancel out two expression (10^100)
|
| ii) Answer is 1 if you compute 10^100 and then add 1 which is
| insignificant.
|
| How do you even cater for these scenarios? This needs more than
| arithmetic.
| Sharlin wrote:
| Uh, what do you mean? The answer is very obviously 1 no matter
| what.
| fsckboy wrote:
| > _The answer is very obviously 1 no matter what_
|
| no, because only in our imaginations and in no place in the
| universe can we ignore significance of measurements. If we
| are sending a spaceship to an interstellar object 1 light
| year away from earth, and the spaceship is currently 25 miles
| from earth (on the way), you are insisting that you know more
| about the distance from earth to the object than you do if
| you think that that distance from the spaceship to the galaxy
| is 587862819274.1 miles
| cubefox wrote:
| Slightly disappointing: The calculator embedded in Google's
| search page also gives the wrong answer (0) for (10^100) + 1 -
| (10^100). So apparently they don't use the insights they gained
| from their Android calculator.
| Aachen wrote:
| Duckduckgo and (apt install) qalc do it correctly fwiw
| ajnin wrote:
| Interesting article but that feels like wasted effort for what is
| probably the most bare-bones calculator app out there. The
| Android calc app has the 4 operations, sin cos tan ^ ln log [?] !
| And that's it. I think most people serious about calculator usage
| either have a physical one or use another more featureful app and
| the others don't need such precision.
| CydeWeys wrote:
| It's not wasted effort at all, as this app comes installed by
| default for over a billion users. Only a tiny fraction will
| ever install another calculator app, so the default one better
| work entirely correctly. When you have that many users it's
| hard to waste effort on making the product better.
| CydeWeys wrote:
| > Obviously we'll want a symbolic representation for the real
| number 1
|
| Sorry, why is this obvious? A basic int type can store the value
| of 1, let alone the more complicated Rational (BigNum/BigNum)
| type they have. I can absolutely see why you want symbolic
| representations for pi, e, i, trig functions, etc., but why one?!
| earthicus wrote:
| I think the issue was that they are representing a real as a
| _product_ of a rational and that more complicated type, so
| without a symbolic representation for 1, when representing and
| rational, they would have to multiply it by a RRA
| representation of 1 which brings in all the decision problem
| issues.
| ChadNauseam wrote:
| Yep, this is exactly it!
| ChadNauseam wrote:
| Sorry for being unclear about this. A number is being expressed
| as a rational times a real. In the case where the rational is
| exactly the number we want, we want to be able to set the real
| to 1, so the multiplication has no effect
| ComputerGuru wrote:
| Because they express numbers as rational times a real, so the
| real in all those cases would be one. When it's one, you do
| rational math as normal without involving reals.
| stackedinserter wrote:
| Yes, anyone can make a calculator.
|
| I don't care if it gives me "Underflow" for bs like e^-1000, just
| give me a text field that will be calculated into result that's
| represented in the way I want (sci notation, hex, binary, ascii
| etc whatever).
|
| All standard calculators are imitations of a desktop calculator,
| It's insane that we're still dragging this UI into desktop. Why
| don't we use rotary dial on mobile phones then?
|
| It's great that at least OSX have cmd+space where I can type an
| expression and get a quick result.
|
| And yes, I did develop my own calculator, and happily used it for
| many years.
|
| TLDR: the real problem of calculators is their UI, not arithmetic
| core.
| purplezooey wrote:
| "Over the past year or so, I've reluctantly come to the
| conclusion I need to leave Elm and migrate to some other MUA like
| PINE or mutt..."
| semolinapudding wrote:
| That's pretty cool, but the downsides of switching to RRA are not
| only about user experience. When the result is 0.0000000..., the
| calculator cannot decide whether it's fine to compute the inverse
| of that number.
|
| For instance, 1/(atan(1/5)-atan(1/239)-pi/4) outputs "Can't
| calculate".
|
| Well alright, this is a division by zero. But then you can try
| 1/(atan(1/5)-atan(1/239)-pi/4+10^(-100000)), and the output is
| still "Can't calculate" even though it should really be
| 10^100000.
| darkhorse222 wrote:
| I really do think we should just use the symbolic systems of math
| rather than trying to bring natural world numbers into a digital
| number space. It's this mapping that inherently leads to
| compensating strategies. I guess this is called an algebraic
| system like the author mentioned.
|
| But I view math as more of a string manipulation function with
| position-dependent mapping behavior per character and dependency
| graphs, combined with several special functions that form the
| universal constants.
|
| Just because data is stored in digitization as 1 and O, don't
| forget it's more like charged and not charged. Computers are not
| numeric systems, they are binary systems. Not the same thing.
| stevage wrote:
| I really wonder what the business case for spending so much
| effort on such precision was. Who are the users who need such
| accuracy but are using android calculator?
| 6510 wrote:
| while phones are mostly a circus people do try to use them for
| serious things. For a program you make the calculations as
| accurate as the application requires. If you don't know what a
| tool will be used for you never really get to feel satisfied.
| chacha21 wrote:
| I share a lot of thoughts with that, and built my own calculator,
| too A calculator that gives right instead of wrong answers
|
| https://chachatelier.fr/chalk/chalk-home.php
|
| I tried to explain what was going on
| https://chachatelier.fr/chalk/article/chalk.html, but it's not a
| very popular topic :-)
| elif wrote:
| Nah yea you can over engineer anything.
|
| In the year he did this he easily could have just done some minor
| interface tweaks to a ruby repl which includes the BigDecimal
| library. In fact I bet this post to an AI could result in such a
| numerically accurate calculator app. maybe as a Sinatra single
| file ruby web app designed to format to phone resolutions
| natively.
___________________________________________________________________
(page generated 2025-02-16 23:00 UTC)