Commit graph

6 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
d014682206 Add t_is_zero predicates. 2022-09-16 11:09:55 +02:00
Dag-Erling Smørgrav
944782f506 Remove unnecessary headers. 2017-08-23 13:19:59 +02:00
Dag-Erling Smørgrav
a09cdc6318 Fix equality predicates.
The count we passed to memcmp() in mpi_eq() and mpi_eq_abs() was actually the number of significant words in the MPI, rather than the number of bytes we wanted to compare.  Multiply by 4 to get the correct value.

To make the intent of the code more apparent, introduce a private MPI_MSW() macro which evaluates to the number of significant words (or 1-based index of the most significant word).  This also comes in handy in mpi_{add,sub,mul}_abs().

Add a couple of test cases which not only demonstrate the bug we fixed here but also demonstrate why we must compare whole words: on a big-endian machine, we would be comparing the unused upper bytes of the first and only word instead of the lower bytes which actually hold a value...
2017-04-22 05:32:25 +02:00
Dag-Erling Smørgrav
a11c52e896 Refactor the comparison predicates, check for identity first. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
47a0bf838f Add functions for comparing an MPI to an integer. 2017-04-06 19:51:47 +02:00
Dag-Erling Smørgrav
fc99e7973b Split up the 150+ mpi test cases into smaller groups. 2017-04-06 19:51:47 +02:00