]> andersk Git - moira.git/blob - util/gdss/lib/crypto/bignum/c/bn/bnCmp.c
initial import of gdss from the Athena source tree
[moira.git] / util / gdss / lib / crypto / bignum / c / bn / bnCmp.c
1 /* Copyright     Digital Equipment Corporation & INRIA     1988, 1989 */
2 /* Last modified_on Fri Aug 10 17:21:47 GMT+2:00 1990 by shand */
3 /*      modified_on Fri Apr 28 18:36:28 GMT+2:00 1989 by herve */
4
5
6 /* bnCmp.c: a piece of the bignum kernel written in C */
7
8
9                 /***************************************/
10
11 #define BNNMACROS_OFF
12 #include "BigNum.h"
13
14                         /*** copyright ***/
15
16 static char copyright[]="@(#)bnCmp.c: copyright Digital Equipment Corporation & INRIA 1988, 1989, 1990\n";
17
18
19 Boolean BnnIsZero (nn, nl)
20
21 BigNum          nn;
22 BigNumLength    nl;
23
24 /* 
25  * Returns TRUE iff N = 0
26  */
27
28 {
29     return (BnnNumDigits (nn, nl) == 1 && (nl == 0 || BnnIsDigitZero (*nn)));
30 }
31
32                 /***************************************/
33 /*\f*/
34
35
36 BigNumCmp BnnCompare (mm, ml, nn, nl)
37
38          BigNum         mm, nn;
39 register BigNumLength   ml, nl;
40
41 /*
42  * return
43  *              BN_GT   iff M > N
44  *              BN_EQ   iff N = N
45  *              BN_LT   iff N < N
46 */
47
48 {
49     register BigNumCmp result = BN_EQ;
50
51
52     ml = BnnNumDigits (mm, ml);
53     nl = BnnNumDigits (nn, nl);
54
55     if (ml != nl)
56         return (ml > nl ? BN_GT : BN_LT);
57
58     while (result == BN_EQ && ml-- > 0)
59         result = BnnCompareDigits (*(mm+ml), *(nn+ml));
60
61     return (result);
62
63 /**** USE memcmp() instead: extern int memcmp ();
64
65     if (ml == nl)
66     {
67         lex = memcmp (mm, nn, nl*BN_DIGIT_SIZE/BN_BYTE_SIZE);
68         return (lex > 0 ? BN_GT: (lex == 0 ? BN_EQ: BN_LT));
69     }
70     else
71         return (ml > nl ? BN_GT : BN_LT);
72 ******/
73 }
This page took 0.045969 seconds and 5 git commands to generate.