Modulous Operator in Double type

This is a discussion on Modulous Operator in Double type within the C Programming forums, part of the General Programming Boards category; Why cant I assign modulous operator into double data type?! [code] double a; if ( a % == 0)... ... ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    3

    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
    Posts
    6,251
    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%.

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, 12: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 Cprogramming.com
    Replies: 5
    Last Post: 02-21-2004, 05:29 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21