Subversion Repositories planix.SVN

Rev

Rev 33 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "os.h"
2
#include <mp.h>
3
#include "dat.h"
4
 
5
// return neg, 0, pos as abs(b1)-abs(b2) is neg, 0, pos
6
int
7
mpmagcmp(mpint *b1, mpint *b2)
8
{
9
	int i;
10
 
33 7u83 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){
15
		i = b1->top - b2->top;
16
		if(i)
17
			return i;
18
	}
2 - 19
	return mpveccmp(b1->p, b1->top, b2->p, b2->top);
20
}
21
 
22
// return neg, 0, pos as b1-b2 is neg, 0, pos
23
int
24
mpcmp(mpint *b1, mpint *b2)
25
{
33 7u83 26
	int sign;
27
 
28
	sign = (b1->sign - b2->sign) >> 1;	// -1, 0, 1
29
	return sign | (sign&1)-1 & mpmagcmp(b1, b2)*b1->sign;
2 - 30
}