sdiehl / galois-field

Finite field and algebraic extension field arithmetic
MIT License
50 stars 13 forks source link

Divide by zero exception when recip'ing even numbers #33

Closed banacorn closed 2 years ago

banacorn commented 2 years ago

recip x would result in Exception: divide by zero on binary fields when x is even.

I think something's wrong about this piece of code:

https://github.com/adjoint-io/galois-field/blob/3b13705fe26ea1dc03e1a6d7dac4089085c5362d/src/Data/Field/Galois/Binary.hs#L89-L92

banacorn commented 2 years ago

It turned out that my choice of p is wrong. There's nothing wrong with recip. Thank you for your work.