From 740c95533376610ffc709c0abacc3cf8bb984f19 Mon Sep 17 00:00:00 2001 From: mdw Date: Sun, 8 Oct 2000 12:03:16 +0000 Subject: [PATCH] Provide @mp_eq@ and @MP_EQ@ for rapidly testing equality of two integers. --- mp.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mp.h b/mp.h index 5bc465d..5b54513 100644 --- a/mp.h +++ b/mp.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp.h,v 1.9 2000/07/29 17:03:31 mdw Exp $ + * $Id: mp.h,v 1.10 2000/10/08 12:03:16 mdw Exp $ * * Simple multiprecision arithmetic * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: mp.h,v $ + * Revision 1.10 2000/10/08 12:03:16 mdw + * Provide @mp_eq@ and @MP_EQ@ for rapidly testing equality of two + * integers. + * * Revision 1.9 2000/07/29 17:03:31 mdw * Add support for left-to-right bitscanning, for use in modular * exponentiation. @@ -596,6 +600,19 @@ extern mp *mp_lsl(mp */*d*/, mp */*a*/, size_t /*n*/); extern mp *mp_lsr(mp */*d*/, mp */*a*/, size_t /*n*/); +/* --- @mp_eq@ --- * + * + * Arguments: @const mp *a, *b@ = two numbers + * + * Returns: Nonzero if the numbers are equal. + */ + +extern int mp_eq(const mp */*a*/, const mp */*b*/); + +#define MP_EQ(a, b) \ + ((((a)->f ^ (b)->f) & MP_NEG) == 0 && \ + mpx_ueq((a)->v, (a)->vl, (b)->v, (b)->vl)) + /* --- @mp_cmp@ --- * * * Arguments: @const mp *a, *b@ = two numbers -- 2.11.0