G00fy
asked on
+-*/ evaluation
If I have:
// code
int i = 1;
float f = 1.2;
double d = 2.5;
long l = 3L;
\\ code
How will the following functions be evaluated?
// code
i * f;
d * f;
l * i;
........
\\ code
Will the variables I'm using be converted to the lowest bit-value and then calculated? Or will they be converted to the highest bit-value and the result casted to the lowest bitvalue? Or... ??? (with bitvalue I mean the amount of bits of that variable)
// code
int i = 1;
float f = 1.2;
double d = 2.5;
long l = 3L;
\\ code
How will the following functions be evaluated?
// code
i * f;
d * f;
l * i;
........
\\ code
Will the variables I'm using be converted to the lowest bit-value and then calculated? Or will they be converted to the highest bit-value and the result casted to the lowest bitvalue? Or... ??? (with bitvalue I mean the amount of bits of that variable)
ASKER
I'm using Visual C++... On linux I'm using GCC3...
it's better to static_cast<>() it then? That way I'm always sure it's what I want on any compiler?
it's better to static_cast<>() it then? That way I'm always sure it's what I want on any compiler?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you have f = i *f for example, the i could be converted to a float,
otherwise, having i = f * i, the f would become an int.
also, most compilers will throw warnings telling you what they do at this position or how they expect you to explicitely typecast.