X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb/blobdiff_plain/2302cd8615b01bda84e68621ab17c2bfbf4286b9..c973f431a370a3adbcb3c94f76dc6896a7279235:/math/mpint.h diff --git a/math/mpint.h b/math/mpint.h index 637ec10e..6b733d1a 100644 --- a/math/mpint.h +++ b/math/mpint.h @@ -133,7 +133,7 @@ /* --- Do all the arithmetic in negative numbers --- */ \ \ while (_v < _vl && _max > 0) { \ - _i -= *_v << _s; \ + _i -= (type)*_v << _s; \ _s += MPW_BITS; \ _v++; \ _max /= (mpd)MPW_MAX + 1; \ @@ -147,6 +147,31 @@ /* --- Build up the list of conversions to be supplied --- */ +#ifdef ULLONG_MAX +# ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +# endif +# define MPINT_CONV_LLONG(_) \ + _(llong, long long, LLONG_MAX) \ + _(ullong, unsigned long long, ULLONG_MAX) +#else +# define MPINT_CONV_LLONG(_) +#endif + +#ifdef INTMAX_MAX +# define MPINT_CONV_INTMAX(_) \ + _(intmax, intmax_t, INTMAX_MAX) \ + _(uintmax, uintmax_t, UINTMAX_MAX) +#else +# define MPINT_CONV_INTMAX(_) +#endif + +#ifdef HAVE_UINT64 +# define MPINT_CONV_U64(_) _(uint64, uint64, MASK64) +#else +# define MPINT_CONV_U64(_) +#endif + #define MPINT_CONVERSIONS(_) \ _(short, short, SHRT_MAX) \ _(ushort, unsigned short, USHRT_MAX) \ @@ -154,7 +179,14 @@ _(uint, unsigned, UINT_MAX) \ _(long, long, LONG_MAX) \ _(ulong, unsigned long, ULONG_MAX) \ - _(uint32, uint32, MASK32) + MPINT_CONV_LLONG(_) \ + _(uint8, uint8, MASK8) \ + _(uint16, uint16, MASK16) \ + _(uint24, uint24, MASK24) \ + _(uint32, uint32, MASK32) \ + MPINT_CONV_U64(_) \ + MPINT_CONV_INTMAX(_) \ + _(sizet, size_t, (size_t)-1) /* --- @mp_fromINT@ --- * *