diff options
author | rsc <devnull@localhost> | 2004-03-21 14:06:38 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-03-21 14:06:38 +0000 |
commit | b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb (patch) | |
tree | deaa85427ae73a045ddef39395bd286f9d3dc2ff /src/libmp/port/mpcmp.c | |
parent | 498bb22174aa2c76493e8c67b92949271131ebfb (diff) | |
download | plan9port-b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb.tar.gz plan9port-b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb.tar.bz2 plan9port-b3f61791f1e9095ce8ae9c6d6415b4ee94e2f7eb.zip |
Add libmp.
Diffstat (limited to 'src/libmp/port/mpcmp.c')
-rw-r--r-- | src/libmp/port/mpcmp.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libmp/port/mpcmp.c b/src/libmp/port/mpcmp.c new file mode 100644 index 00000000..a2e3cf72 --- /dev/null +++ b/src/libmp/port/mpcmp.c @@ -0,0 +1,28 @@ +#include "os.h" +#include <mp.h> +#include "dat.h" + +// return neg, 0, pos as abs(b1)-abs(b2) is neg, 0, pos +int +mpmagcmp(mpint *b1, mpint *b2) +{ + int i; + + i = b1->top - b2->top; + if(i) + return i; + + return mpveccmp(b1->p, b1->top, b2->p, b2->top); +} + +// return neg, 0, pos as b1-b2 is neg, 0, pos +int +mpcmp(mpint *b1, mpint *b2) +{ + if(b1->sign != b2->sign) + return b1->sign - b2->sign; + if(b1->sign < 0) + return mpmagcmp(b2, b1); + else + return mpmagcmp(b1, b2); +} |