Skip to content

Commit

Permalink
Fix mod math test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtommila committed Jan 27, 2024
1 parent 85815cf commit 7432a5f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2002-2023 Mikko Tommila
* Copyright (c) 2002-2024 Mikko Tommila
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,7 +28,7 @@
import junit.framework.TestSuite;

/**
* @version 1.0.1
* @version 1.13.0
* @author Mikko Tommila
*/

Expand Down Expand Up @@ -114,7 +114,7 @@ public static void testInverse()

for (int i = 0; i < 1000; i++)
{
x = Math.abs(random.nextLong()) % lm;
x = Math.abs(random.nextLong()) % (lm - 1) + 1;

assertEquals(x + " ^ -1 % " + lm, 1L, (long) math.modMultiply(math.modInverse((rawtype) x), (rawtype) x));
}
Expand Down Expand Up @@ -159,7 +159,7 @@ public static void testDivide()
for (int i = 0; i < 1000; i++)
{
x = Math.abs(random.nextLong()) % lm;
y = Math.abs(random.nextLong()) % lm;
y = Math.abs(random.nextLong()) % (lm - 1) + 1;

assertEquals(x + " / " + y + " % " + lm, x, (long) math.modMultiply(math.modDivide((rawtype) x, (rawtype) y), (rawtype) y));
}
Expand Down

0 comments on commit 7432a5f

Please sign in to comment.