Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- integer_and_decimal_part_of_float_number_v1.c
- How can we extract the decimal part of a floating point number ?
- https://stackoverflow.com/questions/499939/how-to-extract-the-decimal-part-from-a-floating-point-number-in-c
- C library function modf()
- double modf(double x, double *integer)
- https://www.tutorialspoint.com/c_standard_library/c_function_modf.htm
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- #include<math.h>
- int main(void)
- {
- double x, fractpart, intpart;
- x = -8.123456;
- fractpart = modf(x, &intpart);
- printf("\n %lf \t float number \n", x);
- printf("\n %lf \t integral part \n", intpart);
- printf("\n %lf \t fraction part\n", fractpart);
- return 0;
- } // main()
RAW Paste Data
Copied