Results 1 to 3 of 3

Math Help - How to mod a decimal

  1. #1
    Junior Member
    Joined
    Dec 2008
    Posts
    70

    How to mod a decimal

    After decrypting an affine cypher I was left with the inverse encoder of \frac{i - 2}{5} with i being the particular letter of the alphabet with a:=0 up to z:=25

    Take S for example, which decodes to Y, but \frac{18-2}{5} = 3.2 = 24 mod 26

    My work around.

    18 + 4\times 26 = 122
    122 - 2 = 120
    \frac{120}{5} = 24

    I don't know how to change decimals into a mod whole number. My get around was to keep adding 26 to i until I got a number ending in 2 or 7 so i could take 2 and divide by 5 and keep in the integers. Obviously this is a rather long winded way of doing it and it is using my inteligence rather than a algorithm a computer can do. I assume there must be a proper way of doing it but I can't find any info on it.

    Thank you.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Mar 2011
    From
    Tejas
    Posts
    3,370
    Thanks
    739

    Re: How to mod a decimal

    it depends on what you're "dividing by".

    if you are dividing by a number that is co-prime to your modulus, then what you are really doing is finding the inverse of the denominator (mod n).

    in this case, you are dividing by 5, and (5,26) = 1. thus 5 is invertible (mod 26).

    it turns out that 1/5 (mod 26) is 21: 5*21 = 105 = 4(26) + 1.

    so 16/5 (mod 26) is 16*21 = 336 = 24 (mod 26). no trial-and-error is required here, you just calculate (i - 2)(21), and reduce it mod 26.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Dec 2008
    Posts
    70

    Re: How to mod a decimal

    Thank you, this solves my problem perfectly. I was using the multiplicative inverse trick already to solve the simultaneous equations, i'm not really sure why it didn't click i could use it here as well, it was past my bedtime to be fair.

    Also sorry, for putting it in the wrong forum, i put it in discrete as this is currently being covered in my discrete math module.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. decimal help
    Posted in the Algebra Forum
    Replies: 1
    Last Post: December 2nd 2008, 08:21 AM
  2. i need some help on decimal?anyone???
    Posted in the Algebra Forum
    Replies: 1
    Last Post: July 11th 2008, 08:22 PM
  3. decimal to fraction on TI-83
    Posted in the Calculators Forum
    Replies: 2
    Last Post: April 30th 2008, 03:40 PM
  4. Decimal
    Posted in the Algebra Forum
    Replies: 2
    Last Post: April 18th 2007, 01:28 PM
  5. decimal
    Posted in the Algebra Forum
    Replies: 2
    Last Post: February 27th 2007, 03:05 PM

Search Tags


/mathhelpforum @mathhelpforum