disabling unary "-" for unsigned types

Clemens eriatarka84 at gmail.com
Wed Feb 17 01:15:03 PST 2010


Steven Schveighoffer Wrote:

> > Even mathematicians don't know what to do about divide by zero. But 2's  
> > complement arithmetic is well defined. So the situations are not  
> > comparable.
> 
> Sure they do, the result is infinity.  It's well defined.

This is a common misconception. Of course it depends on the definition you're working with, but the usual arithmetic on real numbers does not define division by zero. The operation just doesn't exist.

To get a bit more abstract, a so-called ring with unity (an algebraic abstraction of, among many other things, the reals) is a set of things, one of which is called "1", together with operations + and *. Division is defined only insofar as that some elements 'a' may have an inverse 'b' such that a*b=b*a=1. There is no requirement that all elements have an inverse (that would be a "group"), and 0 in the reals in particular doesn't have one. In fact, infinity is not a real number (it's not in the set of "things" we're considering), so it doesn't even make sense to say that the inverse of 0 is infinity.

http://en.wikipedia.org/wiki/Ring_theory

Sorry for off-topic, just riles me to see these half-truths repeated again and again.



More information about the Digitalmars-d mailing list