So following:
double t = 244.233;
int a = (int) t;
is not undefined behaviour since 244 can fit inside int
did I get it right?
Otherwise if it was larger value instead of 244 which didn't fit inside int this would be undefined, did I get it right?
I am more interested in how C does this. But is there difference in this case w.r.t to C++?
From [conv.fpint]:
So, for example, converting 66666.66 to an
int16_t
would be undefined behavior, but converting66.66
is just fine.