On August 9, 2023 at 22:14:17 +0200, Hairy Pixels via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote: >Playing around I had a more questions about pointer operations I've never used >myself. > >1) what does "i := x - x;" do and what is it's purpose and why doesn't "x + x" >work the same?
Pointer subtraction is a reverse operation to adding a number to a pointer; the result of the subtraction is the offset between the two pointers. >2) I've used pointer equality of course but what does "x > p" do and what is >its purpose? Relative position between the two locations in memory? As an example, it may be used to check whether a particular pointer points to a location between the start and the end of an allocated memory block (obviously, you'd need two comparisons for that). Tomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal