42 comments

  • throwawaymaths10 hours ago
    Yes, it&#x27;s all good and nice that your types are sound and you don&#x27;t have panics, but I feel like this could get you in trouble in the real world (gleam also uses this division convention, and people very much use gleam for &quot;real world&quot; things). Suppose you took an average over an unintentionally empty list (maybe your streaming data source just didn&#x27;t send anything over the last minute due to a backhoe hitting a fiber in your external data source&#x27;s data center) and took some downstream action based off of what you think is the rolling average. You could get royally fucked if money is involved.<p>Crashing would have been preferable.<p>1&#x2F;0 = 0 is unsuitable and dangerous for anyone doing anything in the real world.
    • wat100002 hours ago
      People are too scared of crashes. Sure, crashing is not ideal. Best is to do what the program is supposed to do, and if you can’t, then it’s better to produce a friendly error message than to crash. But there are far worse outcomes than crashing. Avoiding a crash by assigning some arbitrary behavior to an edge case is not the right approach.
      • wheybags1 hour ago
        Strongly agree here. IMO libraries should try hard to return sensible error codes (within reason, eg null pointer access is unrecoverable imo) but application code should just crash. And when a library returns an error code, default to just crashing if it fails until you have a compelling reason to do something more complicated.
    • williamdclt4 hours ago
      as so often, the really preferable solution would be to make it impossible to code the wrong thing from the start:<p><pre><code> - a sum type (or some wrapper type) `number | DIVISION_BY_ZERO` forces you to explicitly handle the case of having divided by zero - alternatively, if the division operator only accepted the set `number - 0` as type for the denominator you&#x27;d have to explicitly handle it ahead of the division. Probably better as you don&#x27;t even try to divide by zero, but not sure how many languages can represent `number - 0` as a type.</code></pre>
      • chriswarbo56 minutes ago
        Rather than removing 0 from a numeric type, we can avoid including it at all. For example, we can have a bunch of numeric types like:<p><pre><code> Positive = One | Succ Positive Nat = Zero | Positive NonZeroInt = Positive | Neg Positive Int = Zero | NonZeroInt Rational = Ratio Int Positive </code></pre> etc.<p>Depending on the language, these could be implemented with little or no runtime overhead.
      • tialaramex4 hours ago
        All Rust&#x27;s primitive integer types have a corresponding non-zero variant, NonZeroU8, NonZeroI32, NonZeroU64, NonZeroI128 etc. and indeed NonZero&lt;T&gt; is the corresponding type, for any primitive type T if that&#x27;s useful in your generic code.
      • VMG2 hours ago
        galaxy brain: `number` already includes `NaN`
    • oDot8 hours ago
      I use Gleam in production[0][1], and that is not really an issue.<p>Gleam offers division functions that return an error type, and you can use those if you need that check.<p>They fit a list-length use case well as they work better with a piping syntax which is popular in Gleam.<p>[0] <a href="https:&#x2F;&#x2F;nestful.app" rel="nofollow">https:&#x2F;&#x2F;nestful.app</a><p>[1] <a href="https:&#x2F;&#x2F;blog.nestful.app&#x2F;p&#x2F;why-i-rewrote-nestful-in-gleam" rel="nofollow">https:&#x2F;&#x2F;blog.nestful.app&#x2F;p&#x2F;why-i-rewrote-nestful-in-gleam</a>
      • JumpCrisscross3 hours ago
        OP didn’t say Gleam is dangerous in general. They said it’s dangerous anywhere around physical or financial values. Your app isn’t critically dealing with either, so it’s not really a retort to their point.
        • oDot2 hours ago
          You&#x27;ll find that keeping my client information&#x27;s integrity is as important to me as keeping the financials.<p>That, however, is still not enough to alleviate OP&#x27;s concerns, which is why I&#x27;ve explained how the `1&#x2F;0=0` problem can be entirely avoided.<p>I expect entirely avoiding the problem OP mentioned is enough to alleviate the concerns it raises.
          • JumpCrisscross2 hours ago
            &gt; <i>keeping my client information&#x27;s integrity is as important to me as keeping the financials</i><p>Nobody is questioning your intentions. People writing apps in memory-unsafe languages don’t give fewer shits. They’re just more prone to certain classes of errors.<p>&gt; <i>how the `1&#x2F;0=0` problem can be entirely avoided</i><p>1&#x2F;0 problems are generally expected to be entirely avoided. This is about where the system behaves unexpectedly, whether due to human error or the computer being weird.
            • oDot1 hour ago
              Correct, these are all trade-offs we make when building a product. Choosing between the &quot;1&#x2F;0 crashes your program&quot; problem and the &quot;1&#x2F;0 returns 0&quot; problem is one such tradeoff.<p>All I was doing was clarifying the impression OP gave.<p>Now that we all know the details we can make whatever tradeoff we prefer.
    • gregschlom9 hours ago
      It&#x27;s funny, I hold the exact opposite opinion, but from the same example: In the course of my programming career, I&#x27;ve had at least 3 different instances where I crashed stuff in production because I was computing an average and forgot to handle the case of the empty list. Everything would have been just fine if dividing by zero yielded zero.<p>I&#x27;ve learned my lesson since, but still.
      • throwawaymaths8 hours ago
        What was the problem with crashing? Surely you had Kubernetes&#x2F;GCP&#x2F;ECS restart your container, or if you&#x27;re using a BEAM based language, it would have just restarted<p>&gt; Everything would have been just fine if dividing by zero yielded zero<p>perhaps you weren&#x27;t making business decisions based on the reported average, just logging it for metrics or something, in which case I can see how a crash&#x2F;restart would be annoying.
        • Joker_vD7 hours ago
          &gt; What was the problem with crashing?<p>I imagine the problem was that it crashed the whole process, and so the processing of other, completely fine data that was happening in parallel, was aborted as well. Did that lead to that data being dropped on the floor? Who knows — but probably yes.<p>And process restarts are not instantaneous, just so you know, and that&#x27;s even without talking about bringing the application into the &quot;stable stream processing&quot; state, which includes establishing streaming connections with other up- and downstream services.
    • eru4 hours ago
      Interestingly, RiscV goes with 1&#x2F;0 = 0xFFFF_FFFF (in 32 bit mode).<p>I guess that&#x27;s slightly more of a warning than giving 0.
      • cnity1 hour ago
        It also seems more mathematically appropriate because it is as close to the limit of the reciprocal as one can get with that representation. Now please allow me to duck before being struck by the tomatoes of mathematicians.
  • codeflo18 hours ago
    This article invents a new binary operation, calls it &quot;division&quot; and uses the &quot;&#x2F;&quot; operator to denote it. But the article repeats multiple times that this new operation isn&#x27;t a multiplicative inverse, so it&#x27;s not actually division. For example, (a&#x2F;b)*b=a isn&#x27;t true for this new operation.
    • lilyball11 hours ago
      (a&#x2F;b)*b=a isn&#x27;t true, but that&#x27;s also not true for the math that you&#x27;re thinking of. What is true is IF b≠0 THEN (a&#x2F;b)*b=a. And this definition works just fine even if you define division by zero.<p>Also just to point out, the statement here really is a*b‾*b=a, which might make it more clear why b≠0.
      • snickerbockers11 hours ago
        There&#x27;s no &quot;if&quot; in the division operation. Division is not defined for b=0. a&#x2F;0 is a nonsensical quantity because the zero directly contradicts the definition of division.<p>maybe someday there will be a revelation where somebody proposes that it&#x27;s a new class of numbers we&#x27;ve never considered before like how (1-1), (0-1) and sqrt(-1) used to be nonsensical values to past mathematicians. For now it&#x27;s not defined.
        • AlotOfReading7 hours ago
          Division by zero is perfectly well defined in floating point. x&#x2F;0 = INF and INF*0 = NaN. That means b*(a&#x2F;b) != a if b = 0.<p>It&#x27;s true that it&#x27;s not defined for integer types, but that wouldn&#x27;t make a = b*(a&#x2F;b) true for them either.<p>It&#x27;s also common to define x&#x2F;0 = infinity in the extended real numbers that floating point models.
          • danbruc5 hours ago
            The limit 1&#x2F;x as x goes to zero diverges to plus or minus infinity depending on whether you approach from the right or the left. IEEE 754 uses a signed zero, so defining 1&#x2F;+0 = +INF and 1&#x2F;-0 = -INF makes sense. If you do not have a signed zero, arbitrarily picking either plus or minus infinity makes much less sense and picking their &quot;average&quot; zero seems more sensible. So x&#x2F;0 is not actually +INF - even if you meant +0 and we forget about -0 - it is +INF or -INF depending on the sign of x and NaN if x is +0 or -0.
          • snickerbockers33 minutes ago
            TFA was about mathematics, not computer programs. Mathematically, the <i>limit as b approaches 0 of a&#x2F;b</i> is defined to be +&#x2F;- INF depending whether a and b have matching signs. The limit represents the value that a&#x2F;b asymptotically approaches as b approaches 0. a&#x2F;b for b=0 is still undefined.<p>For a good example of <i>why</i> this needs to be undefined, consider that limit as b approaches zero of a&#x2F;b is both +INF and -INF depending on whether b is &quot;approaching&quot; from the side that matches a&#x27;s sign or the opposite side. At the exact singularity where b=0 +INF and -INF are both equally valid answers, which is a contradiction.<p>also in case you weren&#x27;t aware, &quot;NaN&quot; stands for &quot;not a number&quot;.
          • lou13066 hours ago
            The definitions in the floating point standard make much more sense when you look to 0&#x2F;INF as &quot;something so close to&#x2F;far from 0 we cannot represent it&quot;, rather than the actual concepts of 0 and infinity.
          • eesmith5 hours ago
            In floating point a = b * (a &#x2F; b) is not always a true statement.<p><pre><code> &gt;&gt;&gt; import random &gt;&gt;&gt; random.random() 0.4667867537470992 &gt;&gt;&gt; n = 0 &gt;&gt;&gt; for i in range(1_000_000): ... a = random.random() ... b = random.random() ... if (a == b * (a &#x2F; b)): ... n += 1 ... &gt;&gt;&gt; n 886304 </code></pre> For example:<p><pre><code> &gt;&gt;&gt; a, b = 0.7959754927336106, 0.7345016612407793 &gt;&gt;&gt; a == b * (a &#x2F; b) False &gt;&gt;&gt; a 0.7959754927336106 &gt;&gt;&gt; b * (a &#x2F; b) 0.7959754927336105 </code></pre> This is off by one ulp (&quot;unit in the last place&quot;).<p>And of course the division of two finite floating point numbers may be infinite:<p><pre><code> &gt;&gt;&gt; a, b = 2, 1.5e-323 &gt;&gt;&gt; a 2 &gt;&gt;&gt; b 1.5e-323 &gt;&gt;&gt; b * (a &#x2F; b) inf &gt;&gt;&gt; a&#x2F;b inf </code></pre> As a minor technical point, x&#x2F;0 can be -INF if sgn(x) &lt; 0, and NaN if x is a NaN.
        • acjohnson5510 hours ago
          Did you fully read the article?<p>In modern math, the concept of a field establishes addition and multiplication within its structure. We are not free to redefine those without abandoning a boatload of things that depend on their definition.<p>Division is not inherent to field theory, but rather an operation defined by convention.<p>It seems like you&#x27;re fixating on the most common convention, but as Hilel points out, there is no reason we have to adopt this convention in all situations.
    • tux318 hours ago
      Reusing symbols like +, *, or &#x2F; to define operations that aren&#x27;t the + or the &#x2F; you&#x27;re used to is pretty common in math. It&#x27;s just notation.<p>At the end of the day, the &#x2F; that we have in programming has the same problem as this article&#x27;s &#x2F;, almost all programming languages will return 5&#x2F;2 = 2 when dividing integers, even though 2 * 2 is not 5! Division is not defined for all integers, but it&#x27;s just <i>convenient</i> to extend it when programming.<p>So if some languages want to define 1&#x2F;0 = 0, we really shouldn&#x27;t be surprised that 0*0 is not 1, we already had the (a&#x2F;b)*b != a problem all along!
      • clipsy13 hours ago
        &gt; Reusing symbols like +, *, or &#x2F; to define operations that aren&#x27;t the + or the &#x2F; you&#x27;re used to is pretty common in math. It&#x27;s just notation.<p>Reusing symbols <i>in a different context</i> is pretty common; taking a symbol that is already broadly used in a specific way (in this case, that `a&#x2F;b` is defined for elements in a field as multiplying `a` by the multiplicative inverse of `b`) is poor form and, frankly, a disingenuous argument.
        • BlackFingolfin5 hours ago
          I am a professor for algebra at a research university. I make a point out of teaching my students that `a&#x2F;b` is NOT the same as multiplying `a` by the multiplicative inverse of `b`.<p>The standard example is that we have a well-defined and useful notion of division in the ring Z&#x2F;nZ for n any positive integer even in cases were we &quot;divide&quot; by an element that has no multiplicative inverse. Easy example: take n=8 then you can &quot;divide&quot; 4+nZ by 2+nZ just fine (and in fact turn Z&#x2F;nZ into a Euclidean ring), even though 2+nZ is not a unit, i.e. admits no multiplicative inverse.
      • ilius217 hours ago
        That&#x27;s nonsense. a&#x2F;b is float in Python 3, and even in other languages a&#x2F;b gets closer to it&#x27;s actual value as a and b get bigger (the &quot;limit&quot;, which is the basis of Algebra). So four operations in programming generally do agree with foundations of Algebra. But a&#x2F;0=0 is %100 against Algebra. And it&#x27;s very unintuitive. It&#x27;s basically saying zero is the same as infinity, and therefore all numbers are the same, so why bother having any numbers at all?
        • scarmig17 hours ago
          Floats don&#x27;t have multiplicative inverses, and the floating point operations don&#x27;t give us any of the mathematical structures we expect of numbers. Floating point division already abandons algebra for the sake of usefulness.
          • mjcohen16 hours ago
            Knuth vol 2 has a nice discussion of floating point operations and shows how to reason about them. Wilkinson&#x27;s classic &quot;Rounding Errors in Algebraic Processes&quot; (1966) also has a good discussion.
        • clipsy17 hours ago
          &gt; even in other languages a&#x2F;b gets closer to it&#x27;s actual value as a and b get bigger (the &quot;limit&quot;, which is the basis of Algebra)<p>This is not generally true. 5&#x2F;2 = 2, 50&#x2F;20 = 2, 500&#x2F;200 = 2, and so on no matter how big the numbers get.
          • ilius211 hours ago
            Yes, I meant when the result gets bigger. You get the idea.
            • ncruces8 hours ago
              What&#x27;s the output of this Go program, without going to the playground link?<p><pre><code> print(math.MinInt &#x2F; -1) </code></pre> <a href="https:&#x2F;&#x2F;go.dev&#x2F;play&#x2F;p&#x2F;Vy1kj0dEsqP" rel="nofollow">https:&#x2F;&#x2F;go.dev&#x2F;play&#x2F;p&#x2F;Vy1kj0dEsqP</a>
        • ilius217 hours ago
          If you were to define a&#x2F;0 the most logical choice would be a new special value &quot;Infinity&quot;. The second best choice would be the maximum supported value of the type of a (int, int64 etc). Anything else would be stupid.
          • sidpatil13 hours ago
            What if a is negative?
            • ilius211 hours ago
              Same. Unless you want to differentiate -0 and +0 (which make it more complicated), you can not distinguish infinity from negative infinity.
    • ashton31418 hours ago
      Multiplicative inverse happens to be a convenient way to define division in the reals, but there are cases when multiplicative inverses do not correspond to any notion of division. E.g. take a finite ring of integers, like what you’d use for cryptography or heck any operation on an `int`!<p>It’s all just definitions. Always has been.
    • beala17 hours ago
      Under what definition of division is (a&#x2F;b)*b=a true for all values?
      • sadeshmukh11 hours ago
        The one that excludes 0. It&#x27;s not a terribly complicated thing to restrict domain: you don&#x27;t expect, for example, complex values in real-valued functions.
      • mjcohen16 hours ago
        If 0 is not an allowable value for b is necessary but not generally sufficient.
        • beala15 hours ago
          Can you say more? If &quot;0 is not an allowable value for b&quot;, then it seems to me that (a&#x2F;b)*b=a isn&#x27;t true for all values. Specifically, it&#x27;s false when b=0.<p>IIUC, codeflo is arguing that the division operation defined in the article isn&#x27;t &quot;actual division&quot; because (a&#x2F;b)*b=a isn&#x27;t true for all values. But I can&#x27;t think of a definition of division that satisfies that criteria.
          • jraph11 hours ago
            When we say &quot;is not an allowable value&quot;, we are speaking about the domain [1]: all the values for which the function is defined. When we say &quot;for all values&quot;, we implicitly mean for all values of the domain.<p>The parallel in programming would be the contract : you provide a function that works on a given set of values. Or the type: the function would &quot;crash&quot; if you passed a value not of the type of its parameter, but it is admitted it won&#x27;t be done.<p>(In the remaining I&#x27;m referring to 1&#x2F;x instead of a&#x2F;b to simplify things a bit)<p>Another way of saying it is that the function is undefined for 0. (Or on {0}). Then the property is true for all values (on which the function is defined, but saying it is redundant, the function can&#x27;t be called outside its domain, it is an error to try to do this).<p>The domain is often left out &#x2F; implicit, but it is always part of the definition of a function.<p>0 is not in the domain, so it&#x27;s not to be considered at all when studying the function (except maybe when studying limits, but the function will still not be called with it).<p>[1] <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Domain_of_a_function" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Domain_of_a_function</a>
          • zzo38computer11 hours ago
            If &quot;0 is not an allowable value for b&quot;, then (a&#x2F;b)*b=a is not defined when b=0, so it is neither true nor false, since you had previously agreed that b=0 is not allowed (regardless of what &quot;&#x2F;&quot; and &quot;*&quot; are meaning in this context).
          • eru4 hours ago
            We don&#x27;t allow division of apples and oranges, either. So why is excluding 0 weird, but excluding ice cream as an argument is not?
  • amai1 hour ago
    But 0&#x2F;1 = 0. So 1&#x2F;0 must be the inverse&#x2F;opposite of zero.<p>And I think if you look at the Riemann sphere, the inverse of zero is the point where +infinity and -infinity meet. I would call that 0^(-1).
    • amai1 hour ago
      Actually this is what Mathematica does:<p><a href="https:&#x2F;&#x2F;math.stackexchange.com&#x2F;questions&#x2F;1294852&#x2F;why-does-wolfram-alpha-say-that-n-0-is-complex-infinity" rel="nofollow">https:&#x2F;&#x2F;math.stackexchange.com&#x2F;questions&#x2F;1294852&#x2F;why-does-wo...</a><p>Mathematica calls this point on the Riemann sphere &quot;complex infinity&quot;.
      • amai58 minutes ago
        See also <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Projectively_extended_real_line#Dividing_by_zero" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Projectively_extended_real_lin...</a>
  • sethev18 hours ago
    I debated this with my boss at my first programming job (this was 20+ years ago). He thought 1&#x2F;0 should be 0 rather than an error because &quot;that&#x27;s what people expect&quot;. My argument was from mathematical definitions (the argument which this blog post picks apart).<p>In retrospect, I see his point better - practical use trumps theory in most language design decisions.<p>I haven&#x27;t changed my mind but the reason has shifted more toward because &quot;it&#x27;s what a larger set of people expect in more situations&quot; rather than mathematical purity.
    • pasquinelli10 hours ago
      i would not expect 1&#x2F;0 to be zero. as you divide by smaller numbers, the quotient gets bigger, so i can&#x27;t understand why someone would expect &#x2F;0 to be zero.
      • iforgotpassword7 hours ago
        If I have five apples and were to divide them among 0 people then nobody gets anything and I can eat them all, so the proper solution would be 5.
        • askvictor7 hours ago
          Paraphrasing you: &quot;If I have five apples and were to divide them among 0 people, how many does each person get?&quot; This sums up one approach to this problem, and can be thought of in a more intuitive manner than the limit approach. The answer could be zero. Or 1. Or 37. In fact, any number makes as much sense as the question. Which is why either an exception is raised, (or +- Inf is returned for floats, but that&#x27;s just the limit approach). But perhaps it would be more fun just to return a random number on divide by zero :)
        • Almondsetat7 hours ago
          you can&#x27;t divide the apples among 0 people and then claim to still have them, because in that case you would have divided them among 1 people
          • dmz736 hours ago
            Like everything in life, it depends... For example: Storage has 5 items that need to be processed. 5 items need to be split equaly between available processes. There are currently 0 available processes so 5 &#x2F; 0 = 0 items to be processed is more correct than either 5 or Nan or infinity.
            • Almondsetat6 hours ago
              Your example is quite vague (e.g. are we dealing with an integer number of items and processes?) and in general if something looks kinda like a division it doesn&#x27;t mean it is exactly division. Just like in math, we have the power to simply say: if COND -&gt; divide normally, else -&gt; do something else.
        • glitchc1 hour ago
          It&#x27;s more like you had five apples and divided them among zero people, which means not even you get to keep them. They were thrown in the trash instead. The answer is zero.
    • throwawaymaths10 hours ago
      1&#x2F;0 = 0 is usually not a practical thing, it&#x27;s to satisfy that the output of the division operator stays in the type and you don&#x27;t want crashes (a &quot;feature&quot; of ponylang and gleam, e.g.). Its kind of a PL wonk thing.<p>It&#x27;s not at all a good idea for very important practical reasons as I outline in a reply to parent.
      • ncruces8 hours ago
        I don&#x27;t want to handle errors after every division and division doesn&#x27;t crash, both sound rather practical, though.
        • AlotOfReading7 hours ago
          The original purpose of defining it to be Nan&#x2F;INF in floating point was exactly that. You&#x27;d do all the work and then check if it was Nan&#x2F;INF at the end without having to check every intermediate result.
          • eru4 hours ago
            If you want to do all the work at the end, &#x27;exceptions&#x27; do exactly that, too.
    • jsnedjdn8 hours ago
      Never have I ever met anybody who would think dividing by zero yields zero O_o<p>If anything it feels natural to yield +&#x2F;-infinity
      • giraffe_lady7 hours ago
        It&#x27;s not about what I think zero division yields I&#x27;ve taken a math class before. It&#x27;s just about representation within the type system. If division can return infinities we can&#x27;t safely combine division with other functions that are expecting ints and floats.<p>Most languages throw an error instead, but there are tradeoffs there too. If you&#x27;ve decided not to throw an error you should at least return a usable number and zero makes more sense than -1 or 7 or a billion or whatever.<p>You could also build the number stack from the ground up to accommodate this edge case, and make it so all arithmetic functions can handle infinities, infinitesimals and limits. I&#x27;ve come across a racket sublang like that but it&#x27;s nearly unusable for the normal common things you want to do with numbers in code.
        • ctenb7 hours ago
          NaN is a valid float, so are infinities
          • giraffe_lady7 hours ago
            They&#x27;re valid according to a spec that doesn&#x27;t mean I want one showing up when I&#x27;m trying to calculate the area of a semicircle or whatever. In the context of getting one by surprise in simple arithmetic they are approximately as bad as zero. Either way you have to decide how to handle it and there are tradeoffs of different approaches, as the article discusses. It&#x27;s not about someone just being ignorant of basic math like the comment I was replying to implied.
            • morningsam6 hours ago
              &gt;In the context of getting one by surprise in simple arithmetic they are approximately as bad as zero.<p>I don&#x27;t think so, because getting 0 in a larger expression might yield a result that looks plausible, leading to hidden bugs. Inf and NaN both are good because they necessarily propagate all the way up to the end result, making it obvious that something went wrong.
              • MereInterest4 hours ago
                Technically, it is possible for floating-point Inf to stop propagating prior to the final result, depending on the operation. For example, 1&#x2F;Inf produces zero, as does exp(-Inf).<p>But those are cases where the larger a value is, the less is contributes to the final value.
    • JumpCrisscross2 hours ago
      &gt; <i>He thought 1&#x2F;0 should be 0 rather than an error because &quot;that&#x27;s what people expect&quot;</i><p>So I saw this in action once, and it created a mess. Private company had a stupid stock dividend mechanism: every shareholder received some fraction, dependent on fundraising, of a recurring floating pool of shares, quantity dependent on operating performance. (TL; DR Capital was supposed to fundraise, management was supposed to operate. It was stupid.)<p>One quarter, the divisor was zero for reasons I can&#x27;t remember. This <i>should</i> have resulted in no stock dividend. Instead, the cap-table manager issued zero-share certificates to everyone. By Murphy&#x27;s Law, this occured on the last quarter of the company&#x27;s fiscal year.<p>Zero-share certificates are used for one purpose: to help a shareholder prove to an authority that they no longer own any shares. Unlike normal share certificates, which are additive, a zero-share certificate doesn&#x27;t add zero shares to your existing shares; it ambiguously negates them. In essence, on that day, the cap-table manager sent every shareholder a notice that looked like their shares had been cancelled. Because their system thought 1 &#x2F; 0 = 0.<p>If you&#x27;re dividing by zero in a low-impact system, it really doesn&#x27;t matter what you output. Zero. Infinity. Bagel. If you&#x27;re doing so in a physical or financial or other high-impact system, the appropriate output is confused puppy.
    • riwsky18 hours ago
      Huh? The article shows why 1&#x2F;0=0 is mathematically sound, and then considers an error preferable in a programming context anyway, because practicality. It’s the opposite of the reasoning you’re describing.
      • petesergeant11 hours ago
        &gt; The article shows why 1&#x2F;0=0 is mathematically sound<p>It does not, because it is not. And the “real mathematicians” that he quotes aren’t supporting his case either, they’re just saying that there are cases where it’s convenient to pretend. If you look at the Wikipedia page for division by zero you may find “it is possible to define the result of division by zero in other ways, resulting in different number systems”: in short, if it’s convenient, you can make up your own rules.
        • Attrecomet10 minutes ago
          &quot;Making up your own rules&quot; is literally what mathematics is, though. Using that as a counterargument to using a specific set of axioms tells me you don&#x27;t understand mathematics.
        • worik11 hours ago
          &gt; in short, if it’s convenient, you can make up your own rules.<p>Yes.<p>People find it confusing that there is no simple model that encapsulates arithmetic. Fields do not capture it in its entirety. The models of arithmetic that describe it end up being extremely complex.<p>Arithmetic is ubiquitous in proofs of other things, and people like the author of this blog cannot get over it.<p>Reality is weird, inconsistent, and weirdly incomplete.<p>Get used to it!
  • rsp198419 hours ago
    As long as lim(1&#x2F;x)_x-&gt;0 = inf, 1&#x2F;0 = 0 doesn&#x27;t make a whole lot of sense, mathematically speaking. I might be wrong but I don&#x27;t think it was addressed in the article either.
    • CharlieDigital18 hours ago
      There&#x27;s a great Radiolab episode[0] that talks about divide by zero in perhaps more conceptual terms.<p><pre><code> KARIM ANI: If you take 10 and divide it by 10, you get one. 10 divided by five is two. 10 divided by half is 20. The smaller the number on the bottom, the number that you&#x27;re dividing by, the larger the result. And so by that reasoning ... LULU: If you divide by zero, the smallest nothingness number we can conceive of, then your answer ... KARIM ANI: Would be infinity. LULU: Why isn&#x27;t it infinity? Infinity feels like a great answer. KARIM ANI: Because infinity in mathematics isn&#x27;t actually a number, it&#x27;s a direction. It&#x27;s a direction that we can move towards, but it isn&#x27;t a destination that we can get to. And the reason is because if you allow for infinity then you get really weird results. For instance, infinity plus zero is ... LATIF: Infinity. KARIM ANI: Infinity plus two is infinity. Infinity plus three is infinity. And what that would suggest is zero is equal to one, is equal to two, is equal to three, is equal to four ... STEVE STROGATZ: And that would break math as we know it. Because then, as your friend says, all numbers would become the same number. </code></pre> [0] <a href="https:&#x2F;&#x2F;radiolab.org&#x2F;podcast&#x2F;zeroworld" rel="nofollow">https:&#x2F;&#x2F;radiolab.org&#x2F;podcast&#x2F;zeroworld</a>
      • v4vvdq18 hours ago
        Then take 10 and divide it by -10 = -1. 10 &#x2F; -5 = -2. 10 &#x2F; -0.5 = -20. So from the other side of the y-axis it behaves the exact opposite. It goes to minus infinity. So at x=0 we would have infinity and minus infinity at the same time. Imho that is why it is undefined.
        • eqvinox11 hours ago
          In IEEE 754 math, x&#x2F;0 for x &lt; 0 is in fact negative infinity.<p><pre><code> &gt;&gt;&gt; np.float64(-1.)&#x2F;0. -inf &gt;&gt;&gt; np.float64(1.)&#x2F;0. inf </code></pre> And you&#x27;re exactly right, 0&#x2F;0 is NaN in 754 math exactly because it approaches negative infinity, zero (from 0&#x2F;x), and positive infinity at the same time.
        • numpad08 hours ago
          I always thought the answer to verbal query &quot;let y=1&#x2F;x, x=0, find y&quot; was &quot;Well, the answer is the Y axis of the plot&quot;. Surprising that people have to be reminded that X can be signed. I&#x27;ve had similar conversation IRL.
        • WithinReason18 hours ago
          on computers you can have negative zeros
          • recursive18 hours ago
            Negative zero is equal to zero, so it&#x27;s not really a distinct number, just another representation of the same value.
            • epidemian12 hours ago
              It&#x27;s equal (as in, comparing them with == is true), but they are not the same value. At least in IEEE 754 floats, which is what most languages with floating point numbers use. E.g., in JS:<p><pre><code> &gt; 1 &#x2F; 0 Infinity &gt; 1 &#x2F; -0 -Infinity &gt; 0 === -0 true &gt; Object.is(0, -0) false</code></pre>
              • eru4 hours ago
                Yes.<p>In a language like C or Rust, you can cast your +0.0 and -0.0 to an integer, and print out the bit pattern. They are different.
          • pasquinelli10 hours ago
            that&#x27;s really just an encoding of the number to help you understand how the hell you got here
      • tbrownaw18 hours ago
        Ordinal and cardinal infinities are different. There are hierarchies of infinities.<p>`1&#x2F;0` and `1&#x2F;0 + 1` aren&#x27;t meaningfully different, so it kinda does make sense for whatever notation to not make a distinction.
      • SAI_Peregrinus18 hours ago
        It&#x27;s even worse than that. The other issue is what happens when you&#x27;ve got a negative number as the numerator (number on top). Then the smaller the denominator (number on bottom) the <i>more negative</i> the result. -10&#x2F;10 = -1. -10&#x2F;5 = -2. -10&#x2F;2 = -20. So if you divide by zero, it&#x27;s obviously negative infinity! And it&#x27;s positive infinity! At the same time.
    • judofyr18 hours ago
      The arguments around limits are addressed towards the end (under &quot;Update 8&#x2F;12&#x2F;2018&quot;):<p>&gt; &gt; If 0&#x2F;0 = 0 then lim_(x -&gt; 0) sin(x) &#x2F; x = sin(0) &#x2F; 0 = 0, but by L’Hospitals’ Rule lim_(x -&gt; 0) sin(x) &#x2F; x = lim_(x -&gt; 0) cos(x) &#x2F; 1 = 1. So we have 0 = 1.<p>&gt; This was a really clever one. The issue is that the counterargument assumes that if the limit exists and f(0) is defined, then lim_(x -&gt; 0) f(x) = f(0). This isn’t always true: take a continuous function and add a point discontinuity. The limit of sin(x) &#x2F; x is not sin(0) &#x2F; 0, because sin(x) &#x2F; x is discontinuous at 0. For the unextended division it’s because sin(0) &#x2F; 0 is undefined, while for our extended division it’s a point discontinuity. Funnily enough if we instead picked x&#x2F;0 = 1 then sin(x) &#x2F; x would be continuous everywhere.<p>Similar examples can be constructed for any regular function which is discontinuous (e.g. Heaviside step function).
    • v4vvdq18 hours ago
      I was also looking for this. And would like to add: lim(-1&#x2F;x)_x -&gt; 0 = -inf That is (in my opinion) the whole point why it is actually undefined. On one side of the y-axis it goes to infinity, on the other to minus infinity. I don&#x27;t see a solution to this and therefore always have accepted that it is undefined.
      • lupire18 hours ago
        No. 1&#x2F;x^2 is undefined at 0 but has the same <i>limit behavior</i>, because <i>limit behavior</i> is not a function from &quot;pairs of (functions from R to R, R)&quot; to R<p>Infinity is not a real number.
        • ganzuul17 hours ago
          Can limit behavior be defined as Cauchy sequences?
    • lupire18 hours ago
      It&#x27;s fine. Infinity isn&#x27;t a real number, so 1&#x2F;x isn&#x27;t continuous at 0, so it doesn&#x27;t matter what the value of 1&#x2F;0 is. All your open sets still behave the way you expect. Whether you choose &quot;this function is undefined here&quot; vs &quot;it&#x27;s impossible to ever reach the value of this function at this value, under any assumptions I&#x27;ll ever care about&quot; is purely a matter of convenience.
      • rsp198418 hours ago
        Yea, but conceptually it&#x27;s a bit smelly to have f(x) get larger and larger the closer x is to 0 and then suddenly have it be 0 once x reaches 0.
        • _carbyau_9 hours ago
          As others have pointed out &quot;larger and larger&quot; is the same when it is negative too. So I think people are just going: positive infinity + negative infinity = 0.<p>Intuitively nice in a sense but I honestly think &#x27;0&#x27; is misrepresenting what is going on here. I&#x27;m ok with it being &#x27; &quot;+ and&#x2F;or -&quot; infinity&#x27; as a new definition.<p>Programmatically I think it should result in a NULL or VOID or similar. I mean, by definition it has no definition.
        • renewiltord10 hours ago
          But once you go behind, it flips suddenly anyway so you could just as well have it be intuitively “halfway between the positive and negative infinities” which is at least fun and could spawn a few “Why is 1&#x2F;x suddenly go to zero” articles on HN in 2053
  • movpasd3 hours ago
    This is all well and fine, but feels like a lot of words to say &quot;it&#x27;s a matter of definition&quot;.<p>The question is what definitions will be useful and what properties you gain or give up. Being a partial function is a perfectly acceptable trade-off for mathematics, but perhaps it makes it difficult to reason about programs in some cases.<p>I suppose the aim of the article is to point out the issue is not one of soundness, which is useful — but I wish more emphasis had been put on the fact that it doesn&#x27;t solve the question of what 1&#x2F;0 should do and produced arguments with regards to that.
  • red_admiral2 hours ago
    EDIT: markup broke my operators<p>In combinatorics and discrete probability, `0**0 = 1` is a useful convention, to the point that some books define a new version of the operator - let&#x27;s call it `***` - and define `a***b = a**b` except that `0***0 = 1` and then use the new operator instead of exponentiation everywhere. (To be clear, `**` is exponentiation, I could write `a^b` but that is already XOR in my mind.)<p>So one might as well overload the old one: tinyurl.com&#x2F;zeropowerzero<p>This causes no problems unless you&#x27;re trying to do real (or complex) analysis.<p>1&#x2F;0 can cause a few more problems, but if you know you&#x27;re doing something where it&#x27;s safe, it&#x27;s like putting the Rust `unsafe` keyword in front of your proof and so promising you know what you&#x27;re doing.
  • tbrownaw17 hours ago
    So, how often do devs actually want a `&#x2F;` that isn&#x27;t the inverse of multiplication?<p>Trying to calculate... I don&#x27;t know, how many 2-disk raid6 groups I need to hold some amount of data is an <i>error</i>, not &quot;lol you don&#x27;t need any&quot;.<p>If my queue consumer can handle 0 concurrent tasks, it will take <i>literally forever</i> to finish, not finish instantly.
    • nlitened7 hours ago
      To be fair, if my queue consumer can handle 0 concurrent tasks, I’d rather it finishes instantly than never.
  • blablabla1235 hours ago
    Sounds legit, infinity is singular and so is 0. I think one problem is also that division isn&#x27;t the only mathematical operation which can produce dubious results. E.g. sqrt(x), arctan(x) which have multiple branches which is why there is often a separate arctan2(x, y) to select the correct branch. Oh well and then there&#x27;s just addition which silently overflows in almost every programming language.<p>Without arbitrary precision numerics and functions which aren&#x27;t explicit about corner cases it&#x27;s always a simplification. However performance-&#x2F;code-wise this is usually not feasible.
    • eru4 hours ago
      Why is infinity singular? There&#x27;s at least positive and negative infinity.<p>And why do you bring up infinity? In regular math, 1&#x2F;0 is literally undefined. It&#x27;s not infinity.
    • DarkNova64 hours ago
      Hilbert&#x27;s Hotel shows nicely that infinity can&#x27;t be singular.
  • bubblyworld6 hours ago
    Consistency depends on your set of axioms. If you are willing to give up various nice properties of division, then you can obviously extend it however you like.<p>My gripe with arbitrary choices like this is that it pushes complexity from your proof&#x27;s initial conditions (&quot;we assume x != 0&quot;) into the body of your proof (every time you use division now you&#x27;ve split your proof into two cases). The former is a linear addition of complexity to a proof, whereas the latter can grow exponentially.<p>Of course, nothing is stopping you from using an initial condition anyway to avoid the case splitting, but if you were going to do that why mess with division in the first place?
  • MathMonkeyMan12 hours ago
    Not that anybody asked me, but I think about it like this:<p>You have a field (a set of &quot;numbers&quot;). Multiplication is defined over the field. You want to invent a notion of division. Let&#x27;s introduce the notation &quot;a&#x2F;b&quot; to refer to some member of a field such that &quot;a&#x2F;b&quot; * b = a.<p>As Hillel points out, you can identify &quot;a&#x2F;b&quot; with a*inverse(b), where &quot;inverse&quot; is the multiplicative inverse. And yes, there is no inverse(0). But really let&#x27;s just stick with the previous definition: &quot;a&#x2F;b&quot; * b = a.<p>Now consider &quot;a&#x2F;0&quot;. If &quot;a&#x2F;0&quot; is in the field, then &quot;a&#x2F;0&quot; * 0 = a. Let&#x27;s consider the case where a != 0. Then we have &quot;a&#x2F;0&quot; * 0 != 0. But this cannot be true if &quot;a&#x2F;0&quot; is in the field, because for every x we have x * 0 = 0. Thus &quot;a&#x2F;0&quot; is not in the field.<p>Consider &quot;a&#x2F;0&quot; with a=0. Then &quot;a&#x2F;0&quot; * 0 = 0. Any member of the field satisfies this equation, because for every x we have x * 0 = 0. So, &quot;a&#x2F;0&quot; could be any member of the field. Our definition of division does not determine &quot;0&#x2F;0&quot;.<p>Whether you can assign &quot;1&#x2F;0&quot; to a member of the field (such as 0) depends on how you define division.
  • enriquto19 hours ago
    I&#x27;d agree to some kind of 1&#x2F;&#x2F;0=0 for ints; but for floats you&#x27;ll take 1&#x2F;0=inf from my cold, dead hands.
  • _Sycamore18 hours ago
    My head-canon with dividing by zero is that 1&#x2F;0 = undefined and 1&#x2F;-0 = -undefined, and that&#x27;s where I leave it because anything less funny than that seems like an impractical answer.
    • jansan6 hours ago
      I am fine if isFinite(1&#x2F;0) returns false.
    • maxk4218 hours ago
      0 &#x2F; 0 = Any number<p>non-zero &#x2F; 0 = No number
      • hgomersall5 hours ago
        0&#x2F;0 might be a specific number. You have to go and use l&#x27;hopitals rule to work out what it might be.
  • dccsillag13 hours ago
    I find it odd that all of the mathematicians cited at the end are actually pretty much CS people, working on proof assistants. Kinda renders that section pointless, IMO (though the comment by Isabelle&#x27;s author was interesting).<p>IMO, whether something like this makes sense is a separate matter. Personally I always just think of division in terms of multiplicative inverses, so I don&#x27;t see how defining division by zero helps other than perhaps making implementation easier in a proof assistant. But I&#x27;ve seen people say that there are some cases where having a&#x2F;0 = 0 works out nicely. I&#x27;m curious to know what these cases are, though.
  • eqvinox18 hours ago
    Note 1&#x2F;0 (or x&#x2F;0 with x&gt;0) isn&#x27;t undefined or an exception in 754 FP math, it&#x27;s +infinity. It&#x27;s 0&#x2F;0 that&#x27;s the problem. Defining 1&#x2F;0=0 isn&#x27;t really helpful imho.
    • yarg18 hours ago
      &gt; Defining 1&#x2F;0=0 isn&#x27;t really helpful imho<p>But it&#x27;s quite a nice way to mask program bugs.
  • d_tr18 hours ago
    Whatever as long as the name does not imply that these are integers, because then it is just wrong. The same holds for overflowing results being clamped or resulting in smaller or negative values due to wraparound. These are not integers.<p>There is only one correct behavior for something named &quot;int&quot;. Give the correct result or throw an error.
    • itishappy13 hours ago
      Agree `int` is the problem. This implies we&#x27;re doing math over all integers, when in most languages what we&#x27;re actually working with are bounded integers. (There&#x27;s some counter-examples, Python and Haskell come to mind.) Calling them sane names like `i32` and `i64` makes it clear that overflow exists.
    • Asooka18 hours ago
      Those are all integers. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Modular_arithmetic" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Modular_arithmetic</a> - &quot;The modern approach to modular arithmetic was developed by Carl Friedrich Gauss in his book Disquisitiones Arithmeticae, published in 1801.&quot; They have been integers for over 200 years now.
      • d_tr17 hours ago
        But if you write a + b and the result is wrapped around or saturated, it&#x27;s not integer addition. It&#x27;s something else and should be written in another way in code and have a different name. I am aware of modular arithmetic.<p>If you have a type named &quot;int&quot; with an operation called &quot;addition&quot;, and that operation is not actually integer addition... it&#x27;s wrong.
      • thaumasiotes18 hours ago
        Wrapping around is correct integer behavior; clamping (&quot;5 + 1 = 5&quot;) isn&#x27;t. Clamping implies immediately that all positive numbers are equal to zero.
        • TapamN3 hours ago
          True correct behavior would have that if a &gt; b, then a + c &gt; b + c also holds true for all integers, but that isn&#x27;t guaranteed for wrapping (or clamping.) (e.g. if 250 &gt; 1, then 250 + 10 &gt; 1 + 10 should be true, but with 8-bit wrapping you would get 4 &gt; 11, which is false.)
  • benlivengood17 hours ago
    Most definitions of division that I have seen use q * d + r = n if q is unique and abs(r)&lt;abs(d), which doesn&#x27;t require the definition of an inverse. Rather, d that exist for n = 1 and r = 0 can be labelled q&#x27;s inverse but it doesn&#x27;t require a new definition.<p>Additionally, if inverses are defined as separate objects then what is 2 plus the inverse of 2? It doesn&#x27;t simplify to 2.5 because there&#x27;s no addition axiom for numbers and multiplicative inverses, or for that matter any rules for inverses with inverses. So you might have 1&#x2F;2 and 5&#x2F;10 but they&#x27;re not equal and can&#x27;t be multiplied together.
  • TrianguloY18 hours ago
    I&#x27;ve always wondered what would happen if we defined &#x2F;0 as a new symbol, for example &#x27;z&#x27;. The same as we define sqrt(-1) as &#x27;i&#x27;. So if you can do 4*sqrt(-1)=4i, you could also do 4&#x2F;0 = 4z. These two seems similar, as in taking something that should not exist, and just letting it exists in a totally different and orthogonal domain.<p>I tried once to investigate the implications, but it quickly became far more complex that with &#x27;i&#x27; and never went far. Still intrigued if this is somewhat interesting or a total time loss though.
    • alganet17 hours ago
      In SQL, if you divide by zero, you get a NULL. If you divide by NULL, you get NULL (any operation involving a NULL yields NULL, even GROUP BY). I call it &quot;a black hole zero&quot;, if it touches anything, that thing becomes a black hole zero.<p>Some languages will wrap division by zero in a special type, a NaN (not a number). You can then reason on top if that NaN if you want to.<p>So, in a sense, there are some people already doing practical stuff with substituting &#x2F;0 for a new symbol.
      • kaoD17 hours ago
        Does it? Under SQL standard or what engine? At least Postgres raises when dividing by zero.
        • alganet17 hours ago
          You&#x27;re right about division by zero. From SQL92:<p><pre><code> 4) The dyadic arithmetic operators &lt;plus sign&gt;, &lt;minus sign&gt;, &lt;as- terisk&gt;, and &lt;solidus&gt; (+, -, *, and &#x2F;, respectively) specify addition, subtraction, multiplication, and division, respec- tively. If the value of a divisor is zero, then an exception condition is raised: data exception-division by zero. </code></pre> However, the &quot;any operation involving NULL yields NULL&quot; is standard:<p><pre><code> 1) If the value of any &lt;numeric primary&gt; simply contained in a &lt;numeric value expression&gt; is the null value, then the result of the &lt;numeric value expression&gt; is the null value. </code></pre> <a href="https:&#x2F;&#x2F;www.contrib.andrew.cmu.edu&#x2F;~shadow&#x2F;sql&#x2F;sql1992.txt" rel="nofollow">https:&#x2F;&#x2F;www.contrib.andrew.cmu.edu&#x2F;~shadow&#x2F;sql&#x2F;sql1992.txt</a><p>So, dividing by NULL is allowed and yields NULL. Dividing by zero yielding NULL is non-standard (I used it though).
    • ganzuul17 hours ago
      1,000,000 grains of sand is a heap of sand (Premise 1) A heap of sand minus one grain is still a heap. (Premise 2) - <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Sorites_paradox" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Sorites_paradox</a><p>So one grain of sand is a heap and then when you remove that grain the heap disappears, but you only removed one grain from a heap so this is impossible because it is discontinuous. One solution is to wrap the problem in fuzzy logic with a &#x27;heapness&#x27; measure.<p>Generalizing this type of solution we have a practice of wrapping paradoxes in other forms of logic. You would define an interface between these logics. For example in Trits (0,1,UNKNOWN) you could define an interface where you can change the type of NOT-UNKNOWN from Trit to Boolean. This would return at least some part of the entropy to the original domain, preserving a continuity. Wave Function Collapse is another example of translating from one logical domain to another.
    • sgentle12 hours ago
      You might be interested in the hyperreal numbers, which sound a bit like the avenue you were exploring.
      • thaumasiotes9 hours ago
        You can&#x27;t divide by zero in the hyperreals any more than you can in the reals.
    • thaumasiotes18 hours ago
      It&#x27;s just a waste of time. The reason no value is conventionally assigned for division by zero is that assigning a consistent value doesn&#x27;t help. When you want a value for that kind of expression at all, you&#x27;ll want different values in different expressions.
  • zzo38computer11 hours ago
    In uxn, the result of division of anything by zero is defined as zero (there are no error conditions in uxn). I did not know that Pony is also doing that. This is not a proper &quot;division&quot; (since it is not always a multiplicative inverse operation), but it does not necessarily have to be (and, as another comment mentions, the integer division operator in many programming languages is not a proper &quot;division&quot; either); it is something else which might use a &quot;&#x2F;&quot; sign or the instruction name &quot;DIV&quot; or whatever.
  • est3 hours ago
    I might be wrong but this looks a lot like an re-implementation of Riemann sphere?
  • dang13 hours ago
    One megathread and a couple small ones. Others?<p><i>1 &#x2F; 0 = 0 (2018)</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42167875">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42167875</a> - Nov 2024 (8 comments)<p><i>What is the best answer to divide by 0</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40210775">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40210775</a> - April 2024 (3 comments)<p><i>1&#x2F;0 = 0</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17736046">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17736046</a> - Aug 2018 (570 comments)
  • bee_rider12 hours ago
    Maybe division by zero should just not exist.<p>If you actually write 1&#x2F;0 in a manner that can be discovered through static analysis, that could just be a compile time error.<p>If you compute a zero, and then divide by it… I dunno. Probably what happened was the denominator rounded or truncated to zero. So, you actually have 1&#x2F;(0+-e), for some type-dependent e. You have an interval which contains a ton of valid values, why pick the <i>one very specific</i> invalid value?
    • worik11 hours ago
      &gt; Maybe division by zero should just not exist.<p>It does not. It is undefined
  • hans_castorp17 hours ago
    MySQL has ignored math rules for ages as well. 1&#x2F;0 yields NULL there
  • jvanderbot18 hours ago
    Q on this post: Is the field rule &quot;Every element Except Zero has ... &quot; (the 9th rule) defined with respect to the additive identity &quot;zero&quot; or the magical other undefined &quot;Zero&quot; that is the number we&#x27;re all familiar with?<p>If so, how weirdly arbitrary that the additive zero is omitted for all multiplicative inverse definitions. (At least it seems to me). I always figured this was a consequence of our number systems, not of all fields.
    • lupire18 hours ago
      I am not familiar with any &quot;magical other undefined Zero&quot;. Please familiarize me :-)<p>What is your, uh, <i>definition</i> of this <i>undefined* number you are familiar with?</i>
      • jvanderbot18 hours ago
        &gt; Every element EXCEPT 0 has a multiplicative inverse, a⁻, such that a*a⁻ = 1.<p>What is &quot;0&quot;? It&#x27;s not defined in the axioms other than additive zero. Or is it multiplicative zero? (1?). Is it the number zero?<p>If it is the additive zero defined in axiom (3), then it just seems weird to me that additive zero is undefined for multiplicative inverse for all fields always and forever.<p>If it is the number zero, then how does that generalize to other fields?<p>If the answer is &quot;Numbers are the first field and all fields generalize that&quot;, then I suppose we are referring to the number (0), and that&#x27;s fine, as other fields are welcome to define their own larger definition of zero that includes the number (0) ... ?
        • clipsy17 hours ago
          The definition is that it is the additive identity for the field; eg x + a = x no matter what value x takes and what field you are considering. This must be unique; suppose a and b are both additive identities for a field, then b + a = b and a + b = a, but commutativity gives us a + b = b + a, resulting in a = b.<p>The reason the additive identity cannot have a multiplicative inverse is likewise fairly straightforward: once again using `a` as our additive identity we have y.(x+a) = y.x for all x, y in our field; distributing on the LHS gives y.x + y.a = y.x for all x, y in our field; subtracting y.x from both sides finally gives us y.a = 0 for all y in our field.<p>You would need to relax one or more of the field axioms to have a structure in which the additive identity can have a multiplicative inverse. I&#x27;m not aware of any algebraic structure of particular interest that would allow a multiplicative inverse of the additive identity, but in general if you&#x27;re interested in reading more on this sort of thing I&#x27;d recommend reading about rings, commutative rings, and division algebras.
        • kaoD17 hours ago
          &quot;Zero&quot; is just a specific element of the field which satisfies being the additive identity as well as the rest of the properties of a field where 0 is mentioned. When the rest of the axioms refer to &quot;zero&quot; they refer to the exact same element of the set that is also the additive identity.<p>It&#x27;s not the &quot;number zero&quot; because a field does not care about numbers, it&#x27;s just elements of a set (which might be numbers like in R&#x27;s case).<p>1 is not &quot;multiplicative zero&quot;, it&#x27;s the &quot;multiplicative identity&quot;.<p>0 and 1 are just the shorthand we give for those elements. because those are the symbols we use in R which is the most common field we deal with in everyday life.<p>Or am I misunderstanding your question?
          • jvanderbot17 hours ago
            Nope that&#x27;s the answer. Additive zero is the only zero.
  • IshKebab18 hours ago
    &gt; It’s saying that Pony is mathematically wrong. This is objectively false.<p>Pff. The author wants to show off their knowledge of fields by defining a &quot;division&quot; operator where 1&#x2F;0 = 0. Absolutely fine. I could define &quot;addition&quot; where 1 + 2 = 7. Totally fine.<p>What I <i>can&#x27;t</i> do is write a programming language where I use the universally recognised &quot;+&quot; symbols for this operation, call it &quot;addition&quot; and claim that it&#x27;s totally reasonable.<p>Under the <i>standard definition of division implied by &#x27;&#x2F;&#x27;</i> it is mathematically wrong.<p>What they obviously should have done is use a different symbol, say `&#x2F;!`. Obviously now they&#x27;ve done the classic thing and made the obvious choice unsafe and the safe choice unobvious (`&#x2F;?`).
    • tmtvl18 hours ago
      &gt; <i>What I can&#x27;t do is write a programming language where I use the universally recognised &quot;+&quot; symbols for this operation, call it &quot;addition&quot; and claim that it&#x27;s totally reasonable.</i><p>As a programmer, you&#x27;re right: we have standard expectations around how computers do mathematics.<p>As a pedant: Why not? Commonly considered &#x27;reasonable&#x27; things surrounding addition in programming languages are:<p>* (Particularly for older programming languages): If we let Z = X + Y, where X &gt; 0 and Y &gt; 0, any of the following can be true: Z &lt; X, Z &lt; Y, (Z - X) &lt; Y. Which we commonly know as &#x27;wrap around&#x27;.<p>* I haven&#x27;t yet encountered a language which solves this issue: X + Y has no result for sufficiently large values for X and Y (any integer whose binary representation exceeds the storage capacity of the machine the code runs on will do). Depending on whether or not the language supports integer promotion and arbitrary precision integers the values of X and Y don&#x27;t even have to be particularly large.<p>* Non-integer addition. You&#x27;re lucky if 0.3 = 0.1 + 0.2, good luck trying to to get anything sensible out of X + 0.2, where X = (2 ^ 128) + 0.1.
      • IshKebab7 hours ago
        &gt; I haven&#x27;t yet encountered a language which solves this issue:<p>Well, Python supports arbitrary precision integers. And some other niche languages (Sail is one I know).<p>I don&#x27;t think &quot;running out of memory&quot; counts as a caveat because it still won&#x27;t give the wrong answer.<p>For floats, I don&#x27;t think it&#x27;s actually unreasonable to use different operators there. I vaguely recall some languages use +. or .+ or something for float addition.<p>Fair point about wrapping.
        • tmtvl5 hours ago
          &gt; <i>Well, Python supports arbitrary precision integers. And some other niche languages (Sail is one I know).</i><p>As a Lisper, I very carefully chose an example to account for arbitrary-precision integers (so X + X where X is, say, 8^8^8^8 (remember, exponentiation is right-associative, 8^8^8^8 = 8^(8^(8^8)))).<p>&gt; <i>I don&#x27;t think &quot;running out of memory&quot; counts as a caveat because it still won&#x27;t give the wrong answer.</i><p>Being pedantic, it doesn&#x27;t give the _correct_ answer either, because in mathematics &#x27;ran out of memory&#x27; is not the correct answer for any addition.
    • Asooka16 hours ago
      It&#x27;s a question of usefulness. If in your problem domain &quot;1+2=7&quot; is the most useful definition, then by all means do that. Why does the semicolon terminate statements and not the universally agreed upon period? Why does the period denote member access? Why is multiplication not denoted by the universally agreed [middle dot &#x2F; cross character] (strike out the one that is not universally agreed in your country). The design and semantics of a programming language ought to be in service of the programs we wish to express, and informed by our decades of experience in human ergonomics. Blind reverence to religions of yore does us no good. Mathematical notation itself has gone through centuries of development and is not universal, with papers within the same field using different notation depending on what strikes the author&#x27;s fancy. To treat it as sacred and immutable is to behave most un-mathematically. Hell, you can still get into a nice hours-long argument about whether or not the set of natural numbers includes zero or not (neither side will accept defeat, even though there is clearly a right answer)!
  • croes18 hours ago
    It’s unexpected and that makes it dangerous.
  • ashoeafoot8 hours ago
    So,it gives you a infinite list with binary system digit values, that produces a ranked infinity?
  • ganzuul17 hours ago
    In the computational domain we hold entropy in high esteem. Arbitrarily assigning a value of 0 does not preserve entropy. We could return a promise that eventually we will not overflow if we get to be very very clever (arbitrary time) so that we can maintain purity.
  • blueblimp18 hours ago
    This sort of convenient semi-arbitrary extension of a partial function is ubiquitous in Lean 4 mathlib, the most active mathematics formalization project today. It turns out that the most convenient way to do informal math and formal math differ in this aspect.
  • jmclnx18 hours ago
    I set this to zero and print a warning&#x2F;error about divide by zero on the log with data that caused it. That log would be sent to the business person worry about.<p>If they ignore it, I do not care, it is the business problem anyway.<p>Worked for me for decades :)
  • anthk2 hours ago
    1&#x2F;0 = NOP in assembly. You just don&#x27;t divide, you skip that operation.
  • daft_pink16 hours ago
    Wouldn’t the logical value when dividing by zero be infinity, because zero can go into any number an infinite number of times?
    • amavect16 hours ago
      Saying 1&#x2F;0=∞ means creating a new number system with ∞ as a number. Now you have to figure out all operations with ∞, like -1*∞, 0*∞, ∞*∞, ∞&#x2F;∞, or ∞-∞.<p>Making wrong definitions creates contradictions. With 1*x=x, ∞&#x2F;∞=1, the associative property x*(y&#x2F;z)=(x*y)&#x2F;z, and ∞*∞=∞:<p>∞ = ∞*1 = ∞*(∞&#x2F;∞) = (∞*∞)&#x2F;∞ = ∞&#x2F;∞ = 1
      • daft_pink15 minutes ago
        But why would we go from what obviously should be a very large boundless number and just replace it with 0. Our few comment discussion is why it’s undefined in a nutshell.
      • zokier3 hours ago
        that&#x27;s largely solved problem. ieee758 defines consistent rules for dealing with infinities. even if don&#x27;t use the floating-point parts and made a new integer format, it almost certainly would make sense to lift ieee754 rules as-is.
    • thaumasiotes9 hours ago
      &gt; Wouldn’t the logical value when dividing by zero be infinity, because zero can go into any number an infinite number of times?<p>No, just look at the graph of f(x) = 1&#x2F;x. +inf can&#x27;t work.<p>It can work if you assume that no numbers are ever negative.
  • mrfinn6 hours ago
    Disagreed. 1&#x2F;0 should be infinity, and computers should be able to handle these concepts. Just look into what is 1&#x2F;0.00000000000[etc]1. And no is not an error, you find out with a very real and tangible example, when you are developing a 3D engine and you want to make the camera to look at vector [ 0, 0, 0 ]. Quick resume: You can&#x27;t, you need to force add a slight displacement so you can skip this silly error.
  • lupire19 hours ago
    <a href="https:&#x2F;&#x2F;xenaproject.wordpress.com&#x2F;2020&#x2F;07&#x2F;05&#x2F;division-by-zero-in-type-theory-a-faq&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xenaproject.wordpress.com&#x2F;2020&#x2F;07&#x2F;05&#x2F;division-by-zer...</a><p>explains Lean&#x27;s behavior. Basically, you use a goofy alternate definition of division (and sqrt, and more), and to compensate you have to assume (or prove based on assumptions) that the things you will divide by are never zero.<p>Hillel&#x27;s pedantry is ill-taken, though, because he starts off with a false accusation that the headline tweet was insulting anyone.<p>Also, 1&#x2F;0=0&quot; is sound only if you <i>change the field axiom.of division</i>, which is fine, but quite rather hiding the ball. If you add &quot; 1&#x2F;0=0&quot; as an axiom to the usual field axioms, you do get an unsound system.
  • hoseja3 hours ago
    1&#x2F;0 = (−∞, ∞)<p>0 ∈ (−∞, ∞)
  • d--b7 hours ago
    The only thing that truly matters is this:<p>When software engineers make mistakes dividing by 0 and end up with Exceptions being raised or NaNs being output, they&#x27;ll usually blame themselves.<p>When the results are wrong numbers all over the place, they&#x27;ll blame the language.<p>There are 2 cases when people are going to &quot;use&quot; x&#x2F;0:<p>1. They made a mistake.<p>2. They KNOW that x&#x2F;0 returns 0 and they take it as a shortcut for (y == 0 ? 0 : x&#x2F;y)<p>Is that shortcut useful? No. Is it dangerous? Yes. Hence, this is a bad idea.
  • kstrauser11 hours ago
    I despise that answer because it’s so context-dependent. What’s? 10&#x2F;10? 1. 5&#x2F;5? 1. .3&#x2F;.3? 1. .0000000578&#x2F;.0000000578? 1.<p>Ergo, x&#x2F;x=1, so 0&#x2F;0=1. You can use the same logic for x&#x2F;0=any rational number.<p>Defining x&#x2F;0=0 is impossibly arbitrary.
  • MaxGripe7 hours ago
    Not zero. Infinity
  • freddealmeida1 hour ago
    God. No.
  • worik11 hours ago
    Division has an intuitive meaning: A divided by B is the number of Bs in A.<p>That is an intuition why division by zero is undefined.<p>Defining it arbitrarily is uninteresting.<p>Disapointing
  • moomin18 hours ago
    Honestly this hurts my head but Hillel is inevitably correct. You can define an explicitly undefined operation to do whatever you like. But what’s the point? There’s no new mathematics you can do with it, no existing behaviours you can extend like this. Normally, when you divide by a small number, you get a large number. Now for some reason it goes through zero. Why not five? Why not seven?<p>Just because it’s formally consistent doesn’t mean it isn’t dumb.
    • lupire18 hours ago
      Because exceptions are expensive, and functions with holes are dumb.<p>&quot;Dumb&quot; is purely a matter of aesthetic preference. Calling things &quot;dumb&quot; is dumb.<p>&gt; Normally, when you divide by a small number, you get a large number. Now for some reason it goes through zero.<p>Zero is not a &quot;small&quot; number. Zero is the zero number. There is no number that is better result than 0 when dividing by 0; &quot;Infinity&quot; is not a real (or complex) number. This itself is GREAT reason to set 1&#x2F;0 = 0. It only ever bothers people who conflate open sets with closed sets, or conflate Infinity with real numbers, so it&#x27;s good have this pop up to force people to think about the difference.
      • akira250118 hours ago
        Sure.. but there are infinite series that sum to a finite value. Perhaps a pertinent example would be summing all the distances between each successive reciprocal of 1:<p><pre><code> Sum[1&#x2F;x - 1&#x2F;(x+1), {x, 1, ∞}] == 1 </code></pre> You do actually need infinity to arrive at that 1.
      • moomin16 hours ago
        Consider that lim -&gt; inf does not mean “It goes to infinity”. Its actual definition has nothing to do with infinity. So your argument about infinity is a red herring.<p>Or try it the other way, tell me what mathematics works better if 1&#x2F;x=0 than 1&#x2F;x=5. If there’s an aesthetic preference displayed here, it’s for mathematics as a tool for reasoning.
      • recursive18 hours ago
        &gt; Zero is not a &quot;small&quot; number. Zero is the zero number.<p>What do you mean by this? Zero is certainly a zero number, but it seems that it might also be a small number simultaneously.
        • thaumasiotes17 hours ago
          For example, zero is the only real infinitesimal value.