Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Modulus of negative numbers

  • 10-05-2008 11:37PM
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    I really hope someone can help me with this.

    I am reading lecture notes and it says the following -

    -12 mod 11 = 10
    -1 mod 11 = 10

    When I do -12 mod 11 and -1 mod 11 on my calculator I get -1 for both.

    Is there a trick or something extra I am missing here?

    Note I am dealing with finite fields.

    Any help greatly appreciated.

    Thanks


Comments

  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    I think the answer has something to do with 22 - 10 = 11, where 22 is a multiple of 11 which is greater than 12.

    Why doesn't the % (in C) and a calculator give the correct answer?


  • Closed Accounts Posts: 6,081 ✭✭✭LeixlipRed


    When it says = 10 it means 10(mod 11). -12 = (-2)(11) + 10 and -1 = (-1)(11) + 10. Not sure you understand modular arithmetic fully to be honest. Or maybe that's not the question you're asking?


  • Closed Accounts Posts: 31 bobzi


    Hi dublindude,

    when working with modular arithmetic in a finite field the remainder should always be non-negative so:
    -12 = -2*11+10 => -12 mod 11 = 10
    -1 = -1*11+10 => -1 mod 11 = 10


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    Thank you for the replies.
    bobzi wrote:
    when working with modular arithmetic in a finite field the remainder should always be non-negative so:
    -12 = -2*11+10 => -12 mod 11 = 10
    -1 = -1*11+10 => -1 mod 11 = 10

    Is this the same as saying if the answer is a minus, just add the modulus to it?

    For example, -12 mod 11 = -1. -1 + 11 = 10.

    Or is that just coincidence?


  • Closed Accounts Posts: 31 bobzi


    yeah that'll work


  • Advertisement
  • Closed Accounts Posts: 6,081 ✭✭✭LeixlipRed


    dublindude wrote: »
    Thank you for the replies.



    Is this the same as saying if the answer is a minus, just add the modulus to it?

    For example, -12 mod 11 = -1. -1 + 11 = 10.

    Or is that just coincidence?

    That's the whole idea basically.

    a is congruent to b (mod n) where a= kn + b. ie some multiple of your modulus plus the remainder. So if a number is outside your "window", i.e. from 0 to n-1 then to bring it inside you can add or subtract multiples of n.


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    Thanks guys! :)


Advertisement