0

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;
Physician
  • 483
  • 2
  • 7

2 Answers2

1

For every programming language I have worked with it will keep the value to the left of the decimal point.

MaxVK
  • 172
  • 2
  • 12
0

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.

Thomas Koelle
  • 3,416
  • 2
  • 23
  • 44