id summary reporter owner description type status milestone component version severity resolution keywords cc 11999 int128_t from cpp_int gives unexpected results when bitshifting Jordi Vermeulen John Maddock "The 128-bit signed integer int128_t from cpp_int gives some unexpected results when using the bitshift operator. If I shift the value -1 left by 31 bits, then shift it back right by 32 bits, I get the value -0 instead of -1. I do not encounter this problem with the signed integers of larger size (256, 512, 1024). The code below illustrates the problem. I'm using g++ 5.3.0 on Linux Mint (I can test it with Visual Studio 2015 on Windows 7 later if desired). To be clear: this only seems to happen when shifting right further than left. If I shift right by 31 they all print -1. It's also not just a bug in the conversion to string: if I multiply by 10, int128_t prints 0, but the rest prints -10. {{{ #include #include #include using namespace boost::multiprecision; int main() { int64_t i0 = -1; i0 <<= 31; i0 >>= 32; std::cout << i0 << std::endl; // prints -1 int128_t i1 = -1; i1 <<= 31; i1 >>= 32; std::cout << i1 << std::endl; // prints -0 int256_t i2 = -1; i2 <<= 31; i2 >>= 32; std::cout << i2 << std::endl; // prints -1 int512_t i3 = -1; i3 <<= 31; i3 >>= 32; std::cout << i3 << std::endl; // prints -1 int1024_t i4 = -1; i4 <<= 31; i4 >>= 32; std::cout << i4 << std::endl; // prints -1 return 0; } }}} " Bugs closed To Be Determined multiprecision Boost 1.60.0 Problem fixed