bazzilic / BigInteger

Continuation of work on the BigInteger implementation for C# initially created by Chew Keong TAN.
29 stars 19 forks source link

Bug in Prime Tests, gcd != 1 #31

Open furun opened 4 years ago

furun commented 4 years ago

There is a bug in some prime tests.

This lines are wrong, it fails to detect if gcdTest.dataLength > 1

if (gcdTest.dataLength == 1 && gcdTest.data[0] != 1)

it should be

if (gcdTest.dataLength > 1 || gcdTest.dataLength == 1 && gcdTest.data[0] != 1)

(I replaced all this check with IsNegative, IsOne, IsOdd, etc. Sad that this code is not supposed anymore, it is the best c# code I know)

bazzilic commented 2 years ago

Hi, .NET now has its own, built-in BigInteger class, which is better than what was implemented here. It lacks some functions, which can be found in our other project (https://github.com/aprismatic/bigintegerext) that extends the built-in class.