chiark / gitweb /
math/mpint.h (MP_TOINT): Convert MP digits to target type before shifting.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Sep 2016 13:24:34 +0000 (14:24 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 11 Sep 2016 13:24:34 +0000 (14:24 +0100)
Otherwise conversions to types wider than `mpw' never actually works.

math/mpint.h

index 1b0a7623db82d16d03b607d1b20dce71b625e027..6b733d1acb4613aa37ea9d3c49e9024921948af3 100644 (file)
   /* --- 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;                                          \