N
Niklaus
Hi,
I would like to know more about casts.What exactly happens
when casts are applied to a variable.I know that if an
object of type int is applied an cast of float the result
would be of type float.
1)
What i would like to know is the about the
internals when a cast is applied ? Say we have
int i = 3;
double j;
j = (double) i;
What happens in the above statement ? Can someone
explain me at bit level or a considerable explantion ?
2)
Also i would like to know what happens say
i = (int)j;
Again an explanation at the bit level would be very helpful.
If we have
3)
float f = 4.3;
int i;
i = (int) f;
What happens here ? How does the truncation take place ?
4)
Is it similar to how int got promoted to double in the question 2.
5)
How are side effects defined ? When do
i say typecasting is an side effect ?
6)
Is truncation a side effect of type casting or not ?
Nik
-
I would like to know more about casts.What exactly happens
when casts are applied to a variable.I know that if an
object of type int is applied an cast of float the result
would be of type float.
1)
What i would like to know is the about the
internals when a cast is applied ? Say we have
int i = 3;
double j;
j = (double) i;
What happens in the above statement ? Can someone
explain me at bit level or a considerable explantion ?
2)
Also i would like to know what happens say
i = (int)j;
Again an explanation at the bit level would be very helpful.
If we have
3)
float f = 4.3;
int i;
i = (int) f;
What happens here ? How does the truncation take place ?
4)
Is it similar to how int got promoted to double in the question 2.
5)
How are side effects defined ? When do
i say typecasting is an side effect ?
6)
Is truncation a side effect of type casting or not ?
Nik
-