How can we extract the decimal part of a floating point number and store the decimal part and the integer part into two separate integer variables?
You use the modf function:
modf
double integral; double fractional = modf(some_double, &integral);
You can also cast it to an integer, but be warned you may overflow the integer. The result is not predictable then.
1.4m articles
1.4m replys
5 comments
57.0k users