From 3ec3f61bb91b47f9dedefdc0a57bee97b4f7cef9 Mon Sep 17 00:00:00 2001 From: flashultra Date: Fri, 20 Dec 2024 14:03:35 +0200 Subject: [PATCH] Fix for Cppia (see issue #11897) --- std/haxe/math/bigint/BigInt_.hx | 6 +++--- tests/unit/src/unit/TestBigInt.hx | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/std/haxe/math/bigint/BigInt_.hx b/std/haxe/math/bigint/BigInt_.hx index e30d9bc20e6..f48f0befccd 100644 --- a/std/haxe/math/bigint/BigInt_.hx +++ b/std/haxe/math/bigint/BigInt_.hx @@ -1034,9 +1034,9 @@ class BigInt_ { private function modInverse32(d:Int):Int32 { var x:Int32; x = d + (((d + 1) & 4) << 1); - x = x * (2 - (d * x)); - x = x * (2 - (d * x)); - x = x * (2 - (d * x)); + x = (2 - (d * x)) * x; + x = (2 - (d * x)) * x; + x = (2 - (d * x)) * x; return x; } diff --git a/tests/unit/src/unit/TestBigInt.hx b/tests/unit/src/unit/TestBigInt.hx index ee32e03a4c5..c29cc807f05 100644 --- a/tests/unit/src/unit/TestBigInt.hx +++ b/tests/unit/src/unit/TestBigInt.hx @@ -2747,9 +2747,9 @@ class TestBigInt extends Test { eq("692421",a.max(b).toString()); } + #if (!lua && !cppia) public function testNextProbablePrime():Void { - #if (!lua && !cppia) var a:BigInt; a = "8329132432461"; eq("8329132432469",a.nextProbablePrime().toString()); @@ -2765,8 +2765,8 @@ class TestBigInt extends Test { eq("40870721",a.nextProbablePrime().toString()); a = 32747015; eq("32747023",a.nextProbablePrime().toString()); - #end } + #end public function testBigIntRandom():Void { @@ -2778,9 +2778,9 @@ class TestBigInt extends Test { } } + #if (!lua && !cppia) public function testBigIntRandomPrime():Void { - #if (!lua && !cppia) var randomPrimeNumber:BigInt = BigInt.randomPrime(5,5); t(randomPrimeNumber.isProbablePrime(5)); randomPrimeNumber = BigInt.randomPrime(11,5); @@ -2795,8 +2795,8 @@ class TestBigInt extends Test { t(randomPrimeNumber.isProbablePrime(5)); randomPrimeNumber = BigInt.randomPrime(156,5); t(randomPrimeNumber.isProbablePrime(5)); - #end } + #end public function testBigIntRandomInRange():Void {