diff --git a/library/bignum.c b/library/bignum.c index eccb9d30f..b2213127a 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -687,7 +687,7 @@ int mpi_cmp_mpi( const mpi *X, const mpi *Y ) return( 0 ); if( i > j ) return( X->s ); - if( j > i ) return( -X->s ); + if( j > i ) return( -Y->s ); if( X->s > 0 && Y->s < 0 ) return( 1 ); if( Y->s > 0 && X->s < 0 ) return( -1 ); diff --git a/tests/suites/test_suite_mpi.data b/tests/suites/test_suite_mpi.data index 0a8c10332..089c7477e 100644 --- a/tests/suites/test_suite_mpi.data +++ b/tests/suites/test_suite_mpi.data @@ -138,6 +138,15 @@ mpi_cmp_mpi:10:"-2":10:"-3":1 Base test mpi_cmp_mpi (Negative values) #3 mpi_cmp_mpi:10:"-2":10:"-1":-1 +Base test mpi_cmp_mpi (Mixed values) #4 +mpi_cmp_mpi:10:"-3":10:"2":-1 + +Base test mpi_cmp_mpi (Mixed values) #5 +mpi_cmp_mpi:10:"2":10:"-3":1 + +Base test mpi_cmp_mpi (Mixed values) #6 +mpi_cmp_mpi:10:"-2":10:"31231231289798":-1 + Base test mpi_cmp_abs #1 mpi_cmp_abs:10:"693":10:"693":0