Floating point in C

Discussion in 'C' started by phaceoff, Jun 14, 2007.

  1. phaceoff

    phaceoff New Member

    Joined:
    Jun 14, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Code:
    float f = whatever;
    if (fmod (f, floor (f)) == 0)
        // f is a whole number
    ...
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice