Thread: Modulous Operator in Double type

  1. #1
    Registered User
    Join Date
    Apr 2012

    Modulous Operator in Double type

    Why cant I assign modulous operator into double data type?!

    [code] double a;
    if ( a % == 0)... ... [\code]

    My compiler says: invalid operands to binary %

    what is operands?

  2. #2
    Registered User
    Join Date
    Jun 2005
    The compiler's right. The standard says that the % operator can only be applied to integral types.

    You've clearly never heard of a dictionary. Most (if not all) english language dictionaries will define operand as a quantity on which a mathematical operation is performed.

    To spell it out, in C, when you write the expression a % b (which gives the remainder left over when dividing a by b) the variables (or values) a and b are the operands.

    In your code "a % == 0" is invalid because you have left out the second operand.

    If you want to do the equivalent of the modulo operator on floating point types, then look up the function fmod() which is declared in <math.h>.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 04-15-2012, 07:10 PM
  2. Modulous operator
    By _arjun in forum C Programming
    Replies: 2
    Last Post: 01-06-2012, 01:02 PM
  3. 'Type double' help D:
    By absoluteZero in forum C Programming
    Replies: 3
    Last Post: 04-18-2011, 12:17 AM
  4. Double type
    By Gordon in forum Windows Programming
    Replies: 7
    Last Post: 09-28-2007, 05:33 AM
  5. Modulous problem (maths, not programming)
    By nickname_changed in forum A Brief History of
    Replies: 5
    Last Post: 02-21-2004, 06:29 AM

Tags for this Thread