Positive

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Oct 5 06:57:19 PDT 2008


KennyTM~ wrote:
> 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.

Depends on the field. The problem is, either notation is hard to google for.

> 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

Where I grew up I think the sign came as a subscript. This is because 
the nonzero "*" sign could then be added as a superscript. The notations 
I know of are (in TeX notation):

non-negative real numbers: R_+
non-zero real numbers: R^*
positive numbers: R_+^*

Rarely used (I never saw them, actually):

non-positive real numbers: R_-
negative numbers: R_-^*

Oh, I just realized that bounded numbers can't express nonzero real numbers.

> 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.

They don't because they have a slightly different purpose and charter.


Andrei



More information about the Digitalmars-d mailing list