Thread: timing

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    timing

    I have a function which keeps getting accessed and I have a static int which keeps track of how many times the function is executed.

    How can I create a conditional if statement to say...

    IF iCount has ran a multiple of x times THEN
    ... Do some stuff

    ie) after 6 execution the statemetent is true, then 12, then 18, etc...

    thanx

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Question

    Will this work...

    (if x is 6)

    Code:
    if ((iCycleCount % 6) == 0)
    ?????????????

  3. #3
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    % is used for the modulo function of integers. The modulo function is the remainder of a division. Take 8/6. You'll get a remainder of 2 and 8%6 gives the same result. For 12/6, you have a remainder of 0. Thus, you have the right idea.
    High elevation is the best elevation. The higher, the better the view!
    My computer: XP Pro SP3, 3.4 GHz i7-2600K CPU (OC'd to 4 GHz), 4 GB DDR3 RAM, X-Fi Platinum sound, GeForce 460, 1920x1440 resolution, 1250 GB HDD space, Visual C++ 2008 Express

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sure.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Timing basic operations in C++
    By StevenGarcia in forum C++ Programming
    Replies: 9
    Last Post: 09-18-2007, 02:10 AM
  2. Performance Timing Function
    By rosicky2005 in forum C++ Programming
    Replies: 11
    Last Post: 05-31-2007, 03:09 PM
  3. My Timing System
    By jmd15 in forum Windows Programming
    Replies: 4
    Last Post: 01-01-2006, 11:43 PM
  4. Games - timing
    By Magos in forum Game Programming
    Replies: 7
    Last Post: 03-06-2004, 11:32 AM
  5. Timing in Windows
    By steinberg in forum Windows Programming
    Replies: 3
    Last Post: 07-14-2002, 12:43 AM