Solved

# VC++ How to convert between double calculation results and long

Posted on 2010-01-12

Hi,

I have 4 variables:

integer integer_var

integer integer_var2

double double_var

long long_var

I need to calculate the long_var variable in the following way:

long_var=(integer_var)*(integer_var2)/100)

I wrote it in the following way

long_var=long(double(integer_var)*double(integer_var2)/100)

Is it OK to write it this way?

My program crashes (possibly for other reason) but I noticed that the long_var variable equals to zero althogh (double(integer_var)*double(integer_var)/100)=10043.45

If I write the calculation without the double and the long:

long_var=((integer_var)*(integer_var)/100)

I get compiler warnings.

What is the correct way to write it?

Thanks

Thanks