Subject: [Boost-bugs] [Boost C++ Libraries] #13109: Incorrect result when casting from multiprecision::uint128_t to unsigned long long.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-07-07 01:54:31
#13109: Incorrect result when casting from multiprecision::uint128_t to unsigned
long long.
------------------------------+----------------------------
Reporter: gvisser@⦠| Owner: John Maddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
Version: Boost 1.63.0 | Severity: Problem
Keywords: |
------------------------------+----------------------------
I found in Boost 1.63.0 on:
Ubuntu 14.04.5 with g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4,
64-bit Windows 10's Windows Subsystem for Linux with g++ (Ubuntu
5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609.
code snippet:
uint128_t b128 = 0xFFFFFFFFFFFFFFFFFFFFFFFFC0A800FF_cppui;
unsigned long long ull( static_cast<unsigned long long>( b128 ) );
printf( "ull: %016llX\n", ull );
The output is:
ull: FFFFFFFFFFFFFFFF
Under Windows 10 and Visual Studio 2015 the output is:
ull: FFFFFFFFC0A800FF
The work around I'm using is to mask out the upper 64 bits:
ull = static_cast<unsigned long long>(b128 & 0x0FFFFFFFFFFFFFFFF);
Thanks,
Gary Visser
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13109> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-07-07 01:57:55 UTC