CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    15

    How to add some interval?

    I have a list of time stamp. like 1.00001, 1.10004, 1.100345 .............. 10.99999
    I want to add 0.08 second in every 0.02 second interval.
    How to write code for this?
    Pls. help.

  2. #2
    Join Date
    Oct 2008
    Posts
    1,456

    Re: How to add some interval?

    first of all, if the format is fixed and bounded as it seems it's better to translate the time stamps in integral units ( in your case, 10uS units ); in this way, you save the potential problems of float comparisons/accumulation. Then, if I understood what you meant right, you can simply traverse the vector of time stamps adding 8000 to a counter whenever <input time stamp>/2000 changes ( supposing the first interval starts from 0 and intervals are left-closed, right-open ), then the output time stamp will be simply <input time stamp> + <counter>.

  3. #3
    Join Date
    Sep 2010
    Posts
    15

    Re: How to add some interval?

    @loves oi,
    Thanks for your reply.
    I have a list of time stamps from 1.000000 second to 10.999999 second. The gap between two time stamp is random.
    Now I want to add 0.08 second in every 0.02 second interval. (i.e. after 0.02 second there will be 0.08 second rest time (or say gap))
    Example 1: ---working time (when 0.02 sec) ----------- take 0.80 sec rest------ continue work for 0.02 second---------- take 0.80 rest------
    Example2: (I don't know exactly, whether it's like this, but the concept is as below)
    Original changed
    1.000000 1.000000
    1.000010 1.000010
    ......... ...............
    1.020010 1.020010 + 0.08
    1.031010 1.031010+ 0.08
    ............ ...............
    1.035010 1.035010+ 0.08
    1.040010 1.040010+ (0.08 *2)
    Last edited by ritika_sharma82; April 5th, 2011 at 03:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured