Getting a divide by 0 error when using a modulus with a number below 1.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kittiquel
    New Member
    • Jan 2013
    • 2

    Getting a divide by 0 error when using a modulus with a number below 1.

    I am trying to get a remainder of a number with a = 0.9144, rm = ry % a; however, I keep getting a divide by zero error (I believe due to the program rounding 0.9144 down to the integer 0). Is there anyway to fix this?
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    I think % (mod) is only used with integers.I think you need to use:
    Code:
    fmod(). e.g. cout<<fmod(7.6,2.5)<<endl;//prints 0.1

    Comment

    • Kittiquel
      New Member
      • Jan 2013
      • 2

      #3
      Thanks! I think I got it now.

      Comment

      Working...