Error!!!

This is a discussion on Error!!! within the C Programming forums, part of the General Programming Boards category; CC complier gives me invalids operands to binary % error Code: if((m%(f_accept*N))==0.0) {... ..... }...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    55

    Error!!!

    CC complier gives me

    invalids operands to binary %

    error

    Code:
    if((m%(f_accept*N))==0.0)
    {...
    .....
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    % can only be used with integer values/variables. Maybe you should lookup fmod().

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    55
    Can you explain more? Here f_accept is double and m and N are basically integers.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    There's a difference between "int" and "basically integers". The things on the left and the right of % must be ints. Since f_accept is not an int, neither is f_accept*N.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    55
    Ok that means i need to use fmod() function to get the remainder.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Or, if they're "basically integers", you could cast to int or something like that.

    If you use fmod(), don't forget to include math.h . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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