generic + numeric + literals = abomination

so so at
Sat Mar 27 07:10:45 PDT 2010

On Sat, 27 Mar 2010 15:54:19 +0200, Bill Baxter <wbaxter at> wrote:

> Note that 'real' is a built in type in D.  It's an 80-bit float on x86
> procs and 64-bit elsewhere.
> So .5L is like cast(real).5.  Not the solution you were looking for.
> --bb

That "r for real!" was joke.
What i mean is a literal/template/placeholder/younameit, explicitly states  
that number is a floating point.
Lets name it "fp".

When i have the code :
scalar m = 0.5fp;

I want compiler to implicitly cast it to typeof(scalar).
so when the scalar is float, m will be 0.5f.

Another example :
Again, lets try pi.

const scalar pi = 3.14{longest you can find}fp

Now whenever i switch precision, by changing the type of scalar, i got the  
pi in that precision.

Thanks! :)

Using Opera's revolutionary e-mail client:

More information about the Digitalmars-d-learn mailing list