Positive

KennyTM~ kennytm at gmail.com
Sun Oct 5 03:18:24 PDT 2008


Walter Bright wrote:
> Andrei Alexandrescu wrote:
>> About proliferation of types: I don't think that follows at all. Math 
>> found positive numbers special enough to dedicate them a special 
>> notation (|R with subscript "+"). There's also a special notation for 
>> nonzero real numbers (|R with superscript "*"). There is no special 
>> notation for any of the sets you mentioned. That is bound to mean 
>> something.
> 
> I'm not a math major. But in college I took 4 years of math, up through 
> integration in the complex plane and branch cuts (which I never did 
> properly understand <g>). Every engineering/physics class was a math 
> class. I never saw this notation. I am not suggesting it doesn't exist, 
> just that it became commonplace fairly recently, or that it isn't 
> commonplace at least at the undergraduate level. This plays into the 
> numbers issue you mentioned.

Probably they'd used (0, +∞) and [0, +∞) instead.

---

BTW, negative real numbers can also be indicated as ℝ⁻ (R^- if Unicode 
is not supported). Is it now special enough to deserve a Negative!() 
template? :p

I think these sign checking should be done through contracts or 
"conditional template" (? whatever it's called; I haven't used one of 
these yet) instead. Unless you can runtime check that

   Positive!(double) x = 6;
   Positive!(double) y = 12;
   Positive!(double) z = void;
   z = x - y;  // raises error.
   Positive!(double) w;
   din.readf("%g", &w);  // raises error if user enters negative number.

But I don't think uint, etc now even do these checks.



More information about the Digitalmars-d mailing list