www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - cast + aritmetic expr bug

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Following line:

writef("Performance = %g\n", cast(double)(n) / (cast(double)(ms1) * 
1000.0));

Produces compilation error:

alphablend.d(79): C style cast deprecated, use cast(ms1)(*(1000))

Did I miss something?

Variables declared as:
long ms1; int n; 
Feb 11 2005
next sibling parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
Does it work properly if you use:

writef("Performance = %g\n", cast(double) n / (cast(double) ms1 * 1000.0));

Or similar?  I believe the problem is (n) and (ms1).  You could also use 
like (n + 0) and (ms1 + 0)...

-[Unknown]


 Following line:
 
 writef("Performance = %g\n", cast(double)(n) / (cast(double)(ms1) * 
 1000.0));
 
 Produces compilation error:
 
 alphablend.d(79): C style cast deprecated, use cast(ms1)(*(1000))
 
 Did I miss something?
 
 Variables declared as:
 long ms1; int n; 
 
 

Feb 12 2005
parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
This way:

writef("Performance = %g\n", cast(double) n / (cast(double) ms1 * 1000.0));

it works. Thanks.



"Unknown W. Brackets" <unknown simplemachines.org> wrote in message 
news:cukdb9$s0o$1 digitaldaemon.com...
 Does it work properly if you use:

 writef("Performance = %g\n", cast(double) n / (cast(double) ms1 * 
 1000.0));

 Or similar?  I believe the problem is (n) and (ms1).  You could also use 
 like (n + 0) and (ms1 + 0)...

 -[Unknown]


 Following line:

 writef("Performance = %g\n", cast(double)(n) / (cast(double)(ms1) * 
 1000.0));

 Produces compilation error:

 alphablend.d(79): C style cast deprecated, use cast(ms1)(*(1000))

 Did I miss something?

 Variables declared as:
 long ms1; int n; 


Feb 12 2005
prev sibling parent Derek <derek psych.ward> writes:
On Fri, 11 Feb 2005 23:48:07 -0800, Andrew Fedoniouk wrote:

 Following line:
 
 writef("Performance = %g\n", cast(double)(n) / (cast(double)(ms1) * 
 1000.0));
 
 Produces compilation error:
 
 alphablend.d(79): C style cast deprecated, use cast(ms1)(*(1000))
 
 Did I miss something?
 
 Variables declared as:
 long ms1; int n;

Just move the parenthesis... writef("Performance = %g\n", (cast(double)n) / ( (cast(double)ms1) * > 1000.0)); I think that the reason is that the form '(' identifier ')' looks like a C-style cast, as well as looking like a single-term expression. It is because of this ambiguity that C-style casts are deprecated. -- Derek Melbourne, Australia
Feb 12 2005