# Safe pointer arithmetic

Note that if you are using 32-bit addressing, as will be the case by default (see 32-bit addressing, you should use ordinary long integer arithmetic and should not use `UADD` and `USUB`.

However if you have used `SETFLAGS` to enforce the 64K memory limit, whenever you wish to add or subtract something from an integer which is an address of something (or a pointer to something) you should use `UADD` and `USUB`. If you do not, you will risk an ‘`Integer overflow`’ error.

An integer address can be any value from 0 to 65535. An integer variable can hold the full range of addresses, but treats those values from 32768 to 65535 as if they were -32768 to -1. If your addition or subtraction would convert an address in the 0-32767 range to one in the 32768-65535 range, or vice versa, this would cause an ‘Integer overflow’.

`UADD` and `USUB` treat integers as if they were unsigned, i.e. as if they really held a value from 0 to 65535.

For example, to add 1 to the address of a text string (in order to skip over its leading byte count and point to the first character in the string), use `i%=UADD(ADDR(a$),1)`, not `i%=ADDR(a$)+1`.

`USUB` works in a similar way, subtracting the second integer value from the first integer, in unsigned fashion for example, `USUB(ADDR(c%),3)`.

`USUB(x%,y%)` has the same effect as `UADD(x%,-y%)`.