projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
General robustification.
[u/mdw/catacomb]
/
mp.h
diff --git
a/mp.h
b/mp.h
index
bf0303a
..
bfed14a
100644
(file)
--- a/
mp.h
+++ b/
mp.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: mp.h,v 1.1
6 2002/10/15 22:57:22
mdw Exp $
+ * $Id: mp.h,v 1.1
8 2004/04/03 03:32:05
mdw Exp $
*
* Simple multiprecision arithmetic
*
*
* Simple multiprecision arithmetic
*
@@
-30,6
+30,12
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: mp.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: mp.h,v $
+ * Revision 1.18 2004/04/03 03:32:05 mdw
+ * General robustification.
+ *
+ * Revision 1.17 2003/05/16 09:09:24 mdw
+ * Fix @mp_lsl2c@. Turns out to be surprisingly tricky.
+ *
* Revision 1.16 2002/10/15 22:57:22 mdw
* Handy new comparison macros.
*
* Revision 1.16 2002/10/15 22:57:22 mdw
* Handy new comparison macros.
*
@@
-726,16
+732,22
@@
extern int mp_testbit(mp */*x*/, unsigned long /*n*/);
extern mp *mp_setbit(mp */*d*/, mp */*x*/, unsigned long /*n*/);
extern mp *mp_clearbit(mp */*d*/, mp */*x*/, unsigned long /*n*/);
extern mp *mp_setbit(mp */*d*/, mp */*x*/, unsigned long /*n*/);
extern mp *mp_clearbit(mp */*d*/, mp */*x*/, unsigned long /*n*/);
-/* --- @mp_lsl@, @mp_lsr@ --- *
+/* --- @mp_lsl@, @mp_ls
lc@, @mp_ls
r@ --- *
*
* Arguments: @mp *d@ = destination
* @mp *a@ = source
* @size_t n@ = number of bits to move
*
* Returns: Result, @a@ shifted left or right by @n@.
*
* Arguments: @mp *d@ = destination
* @mp *a@ = source
* @size_t n@ = number of bits to move
*
* Returns: Result, @a@ shifted left or right by @n@.
+ *
+ * Use: Bitwise shift operators. @mp_lslc@ fills the bits introduced
+ * on the right with ones instead of zeroes: it's used
+ * internally by @mp_lsl2c@, though it may be useful on its
+ * own.
*/
extern mp *mp_lsl(mp */*d*/, mp */*a*/, size_t /*n*/);
*/
extern mp *mp_lsl(mp */*d*/, mp */*a*/, size_t /*n*/);
+extern mp *mp_lslc(mp */*d*/, mp */*a*/, size_t /*n*/);
extern mp *mp_lsr(mp */*d*/, mp */*a*/, size_t /*n*/);
/* --- @mp_not2c@ --- *
extern mp *mp_lsr(mp */*d*/, mp */*a*/, size_t /*n*/);
/* --- @mp_not2c@ --- *
@@
-845,8
+857,10
@@
extern int mp_cmp(const mp */*a*/, const mp */*b*/);
/* --- Other handy macros --- */
#define MP_ISNEG(x) ((x)->f & MP_NEG)
/* --- Other handy macros --- */
#define MP_ISNEG(x) ((x)->f & MP_NEG)
-#define MP_ISZERO(x)
MP_EQ((x), MP_ZERO
)
+#define MP_ISZERO(x)
(!MP_LEN(x)
)
#define MP_ISPOS(x) (!MP_ISNEG(x) && !MP_ISZERO(x))
#define MP_ISPOS(x) (!MP_ISNEG(x) && !MP_ISZERO(x))
+#define MP_ISODD(x) (!MP_ISZERO(x) && ((x)->v[0] & 1u))
+#define MP_ISEVEN(x) (!MP_ISODD(x))
/*----- Arithmetic operations ---------------------------------------------*/
/*----- Arithmetic operations ---------------------------------------------*/