# Thread: Help with circular queues

1. Hello, I am taking a java computer science course for High School, and I'm a bit confused on circular queues.

We were learning about queues and how they worked, which I believe I have a firm understanding of, but then we ran out of time and my teacher rushed through the circular queues, and I'm a bit cloudy on them.
I know there's something with the modulus and something about having to stop the tail from going into negative indexes in the array...

Can anyone explain what the modulus part is? =\

Thank you for any help,

Bananas

2.

3. The mod or modulus operator gives the remainder after an integer division. In C/C++/Java it's written as %

So,
5 % 3 == 2 (1 + 2/3)
11 % 4 == 3 (2 + 3/4)

Unfortunately, things are a little less straightforward when dealing with negative numbers (in some languages anyway).

-7 % 4 == -3 (-1 - 3/4)

Most people would expect this to give 1 (-2 + 1/4), which is what you'd want for looping around in an array.

4. Thank you for the help

 Bookmarks
##### Bookmarks
 Posting Permissions
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts   BB code is On Smilies are On [IMG] code is On [VIDEO] code is On HTML code is Off Trackbacks are Off Pingbacks are Off Refbacks are On Terms of Use Agreement