Compiler says cast then when done says no can do

Koroskin Denis 2korden at
Wed May 21 06:33:56 PDT 2008

On Wed, 21 May 2008 15:25:48 +0400, Ty Tower <towerty at> wrote:

> I have this line
> double balance=values[6]-values[5]; (values 5&6 are char[])
> so I change to
> double balance=-(double)values[6]-(double)values[5];
> compiler says : C style cast illegal, use cast(double)values[6]
> so I change to
> double balance=cast(double)values[6]-cast(double)values[5];
> compiler says: Error: e2ir: cannot cast from char[] to double
> So as I see it the compiler message in this case at least is wrong or  
> there is a problem casting from a char array to a double . Is it a  
> problem with the compiler message?

What do you want to get by casting from char[] to double?

if `values[5]` stores something like "3.14" then cast won't return what  
you expect,
consider using something like double t = to!(double)("3.14"); or  

Both are defined in std.conv

More information about the Digitalmars-d-learn mailing list