does the symbol % represent remainder as in java ???

thnx

rockie team

does the symbol % represent remainder as in java ???

thnx

rockie team

yes.

% is usually called the “mod” or “modulus” operator, but that means the same thing as remainder.

A couple of things to be careful of. The behavior of % with negative operands is not standardized. In

```
( a % b )
```

if a or b is negative, C only guarantees that the absolute value of the result will be less than b. Better make sure the numbers are positive. One way to do this is to add a multiple of the second operand to the first operand. But be careful of precedence.

The order of precedence of ‘%’ is the same as for ‘*’ and ‘/’, which is higher than for ‘+’ and ‘-’. So

```
( ii + 16 % 8 )
```

evaluates the same as

```
(ii + 0)
```

which is just

```
(ii)
```

Use parens to get what you want:

```
( (ii+16) % 8 )
```

It also makes for more readable code.

-norm