Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Floating point in C (http://www.go4expert.com/forums/floating-c-t4689/)

phaceoff 14Jun2007 20:27

Floating point in C

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???


DaWei 15Jun2007 02:18

Re: Floating point in C

float f = whatever;
if (fmod (f, floor (f)) == 0)
    // f is a whole number

All times are GMT +5.5. The time now is 19:19.