Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 12, 2005 cast + aritmetic expr bug | ||||
---|---|---|---|---|
| ||||
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; |
February 12, 2005 Re: cast + aritmetic expr bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | 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;
>
>
|
February 12, 2005 Re: cast + aritmetic expr bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | 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; |
February 12, 2005 Re: cast + aritmetic expr bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | 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 |
Copyright © 1999-2021 by the D Language Foundation