3

Just like my previous question concerning 'hash'; what exactly is an (or the) "offset?"

Is it a value or data type? Or is it an address location? I have heard it used in different contexts within the computing world. Of course, I have come across it while mounting a disk image; but does it have any other usage than that. I ask this because I have come across the word at other places. Does it have to do anything with memory registers?

Basil Ajith
  • 591
  • 1
  • 5
  • 9

1 Answers1

4

An offset is a difference between two indices, usually memory locations or array indices.

For example, suppose that you have an array $A$ in which each element occupies $x$ bytes. Suppose also that the address of $A$ is $M$. Then the address of the $i$th element (counting from zero) is $M + i \cdot x$. Here $i \cdot x$ is the offset. It's the difference between the address of the $i$th element and the address of the array (which is the address of the zeroth element).

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503