Although we are an embedded shop, we occasionally need a quick (and dirty) utility for testing or simulation. For reasons that are lost in history, VisualBasic was chosen for this. Further, with the introduction of DotNet, we seem to be adopting VbDotNet (VisualBasicDotNet) as the successor for our quick (and even dirtier) utilities. Well, there are a variety of porting issues, which evoke howls of laughter (or is that cursing) among the embedded guys, who really just want to write/burn/test and don't want to have to also write/compile/test the damned simulator. Yesterday, one of them pointed out that 100/0 is no longer "undefined" or "an exception" but is now "infinity." Oh, gawd. Well, all you morons with a PHD in math will have to take a refresher course now. Clearly, MicrosoftMath will be replacing real math, and you'll have to find a way to deal with this infinity thing. -- GarryHamilton ''Did you confirm that this is VB at work? I had a vague memory that the Pentium floating point unit had a mode to select the response to division by zero, and that yielding Inf was one of the possibilities. If so, then it might just have been left in the wrong mode, which is fixable.'' Yup, it's evidently part of the DotNet CLR thing. I note that there is discussion below about whether and when "infinity" is a valid result from anything/0. Since I'm not a MathPhd, could somebody clarify for me what conditions must exist for AnythingByZero to have actual meaning? Thanks. -- gh ''Actually there's Infinity, Positive''''''Infinity, Negative''''''Infinity and NaN in CTS floating-point implementation.'' -- Alexei Marine * You mean IEEE; Microsoft didn't invent the floating point standard. Aside from that, yes, that's true; so? Literally speaking, never, but figuratively it can be a shorthand for talking about a limit that approaches infinity as the dividend approaches zero. To be strictly correct, the shorthand should not be used, but admittedly that shorthand is handy sometimes, as long as it doesn't lead to confusion. Since programming tends to be about pragmatics, it's not '''necessarily''' harmful for software to do this, but I'd be doubly suspicious if there's no way to override that behavior. (This is true even with new fangled non-standard analysis, btw.) ''In non-standard analysis, 100 divided by an infinitesimal around zero will give you positive or negative infinity depending on whether the infinitesimal is positive or negative. None of that "approaches zero" shit however you can't apply the real() function to a hyperreal number until AFTER you've performed the division, because 100 divided by 0 is still undefined.'' You mean will give you ''an'' infinity (positive or negative), or more precisely, an illimited number, which is larger than any finite number but still not equal to the traditional "infinity". And if you multiply that particular illimited number by the particular infinitesimal, you get 100 again, quite unlike if you were operating with infinity or zero. [Hey, uhh, this "approaching zero" crap starts to sound a little like, um, calculus? Is that the intention here?] "crap"? Which liberal arts college has given up on breadth requirements to the extent of allowing humanities majors to escape taking Calculus For Non-majors? ---- There are entirely valid contexts in which 100/0 is infinity, they just don't happen to include the real numbers. I've used symbolic manipulation programs that make the distinction between infinite and simply undefined, and been grateful for it. The arguments against using this in something like VB aren't mathematical, like the above suggests, only pragmatic. ''Quite true; division by zero is formally undefined, but when we do arithmetic by computer we may be modeling any number of things other than the literal arithmetic itself, and there are in fact contexts when we are modeling approach to a limit, which may not be undefined. On the other hand, many consider this to be sloppy procedure.'' I meant formal contexts. It's sloppy because they aren't usually the relevant ones. ''But surely that's just an encoding issue. That is, you can write software that parses "x/0" as if it really had been spelled "infinity". I don't see offhand that there are any formal mathematical contexts where it is possible to literally define division by the additive identity of the ring. At most in a formal domain things can become defined that weren't in the original domain being modeled precisely because the mappings to "values" change, as with formal power series avoiding divergence issues.'' It's possible in contexts where you're not concerned about the ring structure, but are concerned about the geometry. In the projective line (or Riemann sphere if you include complex numbers), 1/0 is infinity in a very formal sense, though infinity times zero is left undefined. Because these spaces are compact, they're a natural place to talk about limits. * The "1/0" point at infinity in the Riemann sphere is a notational device; literal division by zero still isn't defined. It's just the usual limit process. * Entirely false. One of the nice properties of projective lines is that every rational functions has as many zeros as poles, counted by multiplicity. x has a zero at zero and a pole at infinity. 1/x has a pole at zero, and a zero at infinity. That's what counts for division on the Riemann sphere, and it's consistent so long as you accept that certain other products and quotients will be undefined. * I don't follow you. The inclusion of the point '''at''' the pole turns an open set into a closed set, so of course that has nice properties, and yes, it's consistent, but there's still a difference between division and something "that counts for division". True division would be inconsistent if division by zero were defined, that's the whole point. When I include the "point at infinity", that doesn't mean that infinity is a number. If I use nonstandard analysis and operate with illimited numbers, none of them are identical to infinity, nor is any nonstandard infinitesimal equal to zero. And the equivalents in standard analysis are clearly all about limits in the approach to infinity and to zero. Don't forget I already mentioned formal power series' avoidance of divergence issues; there's a difference between division and something that models division. * How so? This is the concept analogous to division in a ring. It doesn't satisfy exactly the same properties, but as nothing does, we have no problem calling it division and denoting it with the same symbol. Compare multiplication of quaternions, octonions, and hexadecions, which satisfy fewer and fewer multiplicative properties but are still called multiplication. And note the projective line has nothing to do with non-standard analysis, they are completely different extensions of the real numbers: one in an algebraic sense and one in an analytic sense (where division and the like are expressed by continuous maps, extended in the normal way). * Well, maybe it's a terminology issue. But those extended algebras are still division algebras, and I would think we've still got a division algebra in the case of the projective line, don't we? To put it another way, what goes wrong if I try to insist that the division by zero is just a shorthand for talking about a limit? What works better by insisting that it's not a shorthand, it really is a division by zero (and that we're then not working in a division algebra)? * Hexadecions, or whatever you call them, aren't a division algebra. And while nothing goes wrong, you defy yourself of a simpler, more portable notion. You can take projective lines over other fields, where taking limits might not be possible, in which case one concept generalizes but the other doesn't. I agree it's partially semantics, but it's rarely an advantage to refuse to define things. For instance, all those first-year calc texts that insist dx has no independent meaning are simply taking a narrow view. * Yes, they are, that's a good point -- although to be fair, the epsilon/delta/Bourbaki rigour was useful prior to nonstandard analysis justifying infinitesimals (obligatory Bishop Berkeley quote "And what are these fluxions? The velocities of evanescent increments. And what are these same evanescent increments? They are neither the finite quantities, not quantities infinitely small, nor yet nothing. May we not call them ghost of departed quantities?") But in which realm other than everywhere-discontinuous functions can you not take limits? * The epsilon-delta stuff is useful, but that's not the same as saying dx has no meaning, it's saying it's meaning lies outside the system in question. Ditto here. Projective lines are often defined over any ring, where limits need not exist in any relevant sense (since many are discrete), and it's a useful notion to have for them. Meanwhile, what do you lose by doing this? The right to say 1/0 is undefined in all contexts, but how valuable is that? * As long as there's no danger of confusion, yes, right you are; ok. :-) I'm not actually disagreeing with you. I just think the above comment about ''MS math'', and about how every real mathematician would leave division by zero undefined, is an unnecessary slur on many mathematicians and on the VB programmers. There are more than enough valid criticisms of the latter. ''True. People tend to be kind of knee-jerk about such things, which sometimes is called for, but other times is overly nitpicky. Or is taking an easy shot.'' ---- I'm actually simultaneously pleased and dismayed to see that the concept is not as clear-cut as I originally thought. There is, however a small problem with the language simply absorbing AnythingByzero and returning infinity: the accounting systems we support don't have a place for that, and we can't do meaningful percentage computations with it. In ''our'' context, AnythingByZero is actually an error -- it must not be allowed -- and if we somehow let a zero divisor through, we need to halt, not "try to make sense of it" and pass on the result. We must now police the inputs and outputs, not only for potential zero divisors, but now also for infinite results. We're all looking forward to this small, tiny, insignificant, meaningless, trivial alteration of our system logic. -- GarryHamilton * Note that, despite the extended discussion above, no one is claiming that division by zero is defined '''over the reals''', which is really what you were asking. But then, computers can't even operate on reals, anyway, only on some rationals (e.g. floating point can't represent 1/3 exactly), so it's back to pragmatics again. * Well, actually I guess I didn't quite sum that up fairly. If you want to pretend that infinity is part of the reals, you can also pretend that division by zero is legit and yields infinity, although then you have to be careful to note that b*(a/b) != a in all cases -- but floating point is already full of such things, so what the hell. A little web searching reinforces my memory: it '''is''' possible to tell the Pentium whether to produce Inf or to raise an exception, and CLR is, I would think, likely to using the FP unit mode rather than implementing divide by zero as Inf in software. See http://www.panopticoncentral.net/articles/916.aspx The problem with trying to fix that, though, is that operating systems typically are loath to change the FP mode on every context switch, because it's huge (512 bytes). And yet, if any given process changes the FP mode to something unsuitable for other processes, it could screw up all the other processes, unless the mode is indeed restored per context switch. Unfortunate. On the bright side, you can typically delay your checks for Inf until higher level modules, since they accumulate. You know, there must be thousands/millions of other people worldwide facing your identical problem, suggesting that the least painful of the various solutions might already have been invented and available if you search forums '''and''' Usenet groups... ---- See: IeeeSevenFiftyFour (IEEE floating point standard) For true rants: ThereIsNoInfinity CategoryRant