Subversion Repositories planix.SVN

Rev

Rev 22 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 26
Line 6... Line 6...
6
int
6
int
7
mpmagcmp(mpint *b1, mpint *b2)
7
mpmagcmp(mpint *b1, mpint *b2)
8
{
8
{
9
	int i;
9
	int i;
10
 
10
 
-
 
11
	i = b1->flags | b2->flags;
-
 
12
	if(i & MPtimesafe)
-
 
13
		return mpvectscmp(b1->p, b1->top, b2->p, b2->top);
-
 
14
	if(i & MPnorm){
11
	i = b1->top - b2->top;
15
		i = b1->top - b2->top;
12
	if(i)
16
		if(i)
13
		return i;
17
			return i;
14
 
18
	}
15
	return mpveccmp(b1->p, b1->top, b2->p, b2->top);
19
	return mpveccmp(b1->p, b1->top, b2->p, b2->top);
16
}
20
}
17
 
21
 
18
// return neg, 0, pos as b1-b2 is neg, 0, pos
22
// return neg, 0, pos as b1-b2 is neg, 0, pos
19
int
23
int
20
mpcmp(mpint *b1, mpint *b2)
24
mpcmp(mpint *b1, mpint *b2)
21
{
25
{
22
	if(b1->sign != b2->sign)
26
	int sign;
-
 
27
 
23
		return b1->sign - b2->sign;
28
	sign = (b1->sign - b2->sign) >> 1;	// -1, 0, 1
24
	if(b1->sign < 0)
-
 
25
		return mpmagcmp(b2, b1);
-
 
26
	else
-
 
27
		return mpmagcmp(b1, b2);
29
	return sign | (sign&1)-1 & mpmagcmp(b1, b2)*b1->sign;
28
}
30
}