0

Say I want to do something like

9.9 % 13

The normal python modulo will give me an output of 9.9. Are there any modules I can import that will instead give me an output of 6 (or more generally an integer value)?

UBears
  • 371
  • 1
  • 4
  • 18
  • 3
    And why should it give 6??? If you meant 9 then just call `int` on the result... – Julien Mar 09 '17 at 01:58
  • I just quickly copied an example from [here](http://math.stackexchange.com/questions/1246584/simplifying-a-decimal-number-under-modular-arithmetic-9-9-pmod13) (admittedly without checking it over first). The important thing is that I want it to return an integer value. My thinking would be that $9.9 \equiv 6 \bmod 13$. I'm writing a version of the baby step-giant step algorithm and I need it for the comparisons. – UBears Mar 09 '17 at 02:01

2 Answers2

1

Just do (99 mod 13 * inverse modulo ( 10, 13)) modulo 13

99 mod 13 = 8, inverse modulo (10,13) = 4

Bleh
  • 441
  • 3
  • 14
-1

9.9 is the only correct answer. Since 9.9 is less than 13, 9.9 is the result of your request. Asking for an import that gives you an integer output is not possible because an integer value is not possible. No matter which module you use.

TL;DR: There are no such modules.

Nairit
  • 161
  • 1
  • 9