kotlin-multiplatform-bignum icon indicating copy to clipboard operation
kotlin-multiplatform-bignum copied to clipboard

Incorrect values for modInverse function

Open HoangNguyen219 opened this issue 9 months ago • 1 comments

Describe the bug Incorrect values for modInverse function

To Reproduce Steps to reproduce the behavior:

    @Test
    fun testModInverse() {
        val a = BigInteger.parseString("54647")
            .modInverse(BigInteger.parseString("1157920"))

        assertEquals(
            BigInteger.parseString("1141223"),
            a
        )
Expected :1141223
Actual   :-16697

Expected behavior In java.math this test is successful:

    @Test
    public void testModInverse() {
        BigInteger a = new BigInteger("54647")
                .modInverse(new BigInteger("1157920"));
        assertEquals(new BigInteger("1141223"), a);
    }

HoangNguyen219 avatar May 12 '24 14:05 HoangNguyen219

Thanks for reporting, I'll give it a look when I have some free time.

ionspin avatar May 12 '24 15:05 ionspin

Fixed in #306

ionspin avatar Jul 14 '24 21:07 ionspin