Does Converting a double to a long, then back to double, guarantees keeping the exact value to the left of the decimal point?
EDIT: Working with C++: Conversion is as follows:
double d_var = func();
long l_var = (long)d_var;
d_var = (double)l_var;
Does Converting a double to a long, then back to double, guarantees keeping the exact value to the left of the decimal point?
EDIT: Working with C++: Conversion is as follows:
double d_var = func();
long l_var = (long)d_var;
d_var = (double)l_var;
For every programming language I have worked with it will keep the value to the left of the decimal point.
For typecast then the fractions are removed when casting, but for range then double can hold bigger numbers than long and therefore becomes something else during a typecast.
At least for common languages I can think of.