I want to get integer part
of double
. But this way does not work for me:
double param, fractpart, intpart;
param = 3.14159265;
fractpart = modf (param , &intpart);
printf ("%f = %f + %f \n", param, intpart, fractpart);
It is due to the fact, that double integer
may have e-notation
. For example, 3.41e10
is correct double number.
My test cases is:
- double -> long long
- 234343.0 -> 234343
- 3.41e10 -> 34100000000
- 19.999999999 -> 19
- -10.1 -> -10
- -0.0000001 -> 0
Is there some beautiful way to complete my task?