When i try to extract the fractional part of a double it seems to be rounding down in C, Is there a way to do it without rounding?
double t = 8.2;
int ipart = (int)t;
long long val = abs((long long)(t*1000000));
long long fpart = (val)%1000000;
fpart gives 199999, Is there a way to get it as 200000 without rounding down? Tried many ways but none of the methods seems to be working for all the numbers.
Intention is to finally convert this double into string which should have the exact value as "8.20000". If i can extract fraction part in long long variable then i can generate the string using snprintf.