Floating point in C

Newbie Member
14Jun2007,20:27   #1
phaceoff's Avatar
Hi!

I'm trying to write a simple program that takes a fairly big number and checks which numbers it is dividable with.

If i create a loop that divides the big number with an increasing floating point variable, I should have the answer when the result is a whole number.

But how do i check if a floating point is a whole number???

-phaceoff
Team Leader
15Jun2007,02:18   #2
DaWei's Avatar
Code:
float f = whatever;
if (fmod (f, floor (f)) == 0)
    // f is a whole number
...