Can we use modulo to compare two floats?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naan
    New Member
    • Nov 2012
    • 1

    Can we use modulo to compare two floats?

    can't we use modulo to compare two float
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    The modulo-division operator (%) is only permitted if both operands are integral types. Floating point operands are not allowed.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      You can fake it by multiplying by 10 to the power of how many decimals you want. Convert to an integer. Do your mod.

      Comment

      • whodgson
        Contributor
        • Jan 2007
        • 542

        #4
        fmod()returns a double from two double arguments and is defined in cmath header

        Comment

        Working...