Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a packetized binary data file that can be referenced in one of two ways:

  1. By an arbitrary time tick counter, and
  2. By a file offset in bytes.

In my example file, I have the following packet locations:

ticks           file offset
729047097              3214   <-- Location of first packet
739047132          37492760   <-- Location of last packet
---------          --------
 10000035          37494046   <-- Differences

I need a function that I can present start and end ticks, start and end offsets, and a candidate number of ticks between the start and end ticks, and have it return the corresponding file offset.

I already know that I can compute a Bytes per Tick value, and then multiply that by (candidate ticks minus start ticks), but what I would like to know is:

  1. What is the general form of this function, and
  2. Is there a name for this general form?
share|cite|improve this question
up vote 4 down vote accepted

If I understand correctly what you're trying to do, it's called linear interpolation, and the formula for it is


where $o_0$, $o_1$ and $t_0$, $t_1$ are the file offsets and ticks at start and end, respectively, and $o(t)$ is the file offset corresponding to tick $t$. The "bytes per tick" value is the fraction on the right. How to arrive at this is explained in the Wikipedia article.

share|cite|improve this answer
Yes! I knew there was a name for it, I just couldn't remember. – Robert Harvey Aug 9 '11 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.