You use the modf
function:
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.
More Related Contents:
- How do I restrict a float value to only two places after the decimal point in C?
- Find the Biggest Number in C, BUT with characters
- Allow only decimal numbers in textbox in C#
- error: incompatible types for a function that returns float in C
- When should I use double instead of decimal?
- Dividing 1/n always returns 0.0 [duplicate]
- getch and arrow codes
- How to convert a Decimal to a Double in C#?
- What operations and functions on +0.0 and -0.0 give different arithmetic results?
- Get decimal portion of a number with JavaScript
- Why is printf round floating point numbers up?
- What is the fastest way to convert float to int on x86
- Does “n * (rand() / RAND_MAX)” make a skewed random number distribution?
- Why does adding a small float to a large float just drop the small one?
- How does printf and co differentiate between float and double
- C: how to break apart a multi digit number into separate variables?
- Can I make gcc tell me when a calculation results in NaN or inf at runtime?
- Status of __STDC_IEC_559__ with modern C compilers
- How to convert Decimal to Double in C#?
- Octal number literals: When? Why? Ever? [closed]
- Is fmod() exact when y is an integer?
- Trouble with float on C [duplicate]
- When does underflow occur?
- Serialize double and float with C
- C printf using %d and %f
- Comparing float and double
- Is there a document describing how Clang handles excess floating-point precision?
- Why do you need an explicit `-lm` compiler option? [duplicate]
- C fundamentals: double variable not equal to double expression?
- How can floating point calculations be made deterministic?