boost::multiprecision::uint128_t sizeof 为 24

boost::multiprecision::uint128_t sizeof is 24

基础数学 (128 / 8 = 16) 的说法不同。我有点失望,想要一些答案 - 因为根据我的习惯,该符号 (type_num_of_bytes_t) 不仅描述了 可以放入变量的数据量 ,还有跨平台固定变量大小,后者更重要的是恕我直言。我做错了什么?

#include "boost/multiprecision/cpp_int.hpp"
using boost::multiprecision::uint128_t;

...

qDebug() << sizeof(uint128_t);

输出:24。

我正在使用标准 x86/64 架构 CPU,在 Windows 上使用 vs2013 进行编译。

更新:boost 版本为 1.61。

cpp_int 1.6.1

When used at fixed precision, the size of this type is always one machine word larger than you would expect for an N-bit integer: the extra word stores both the sign, and how many machine words in the integer are actually in use. The latter is an optimisation for larger fixed precision integers, so that a 1024-bit integer has almost the same performance characteristics as a 128-bit integer, rather than being 4 times slower for addition and 16 times slower for multiplication (assuming the values involved would always fit in 128 bits). Typically this means you can use an integer type wide enough for the "worst case scenario" with only minor performance degradation even if most of the time the arithmetic could in fact be done with a narrower type.

额外的机器字(在 x86/64 8 字节上)使大小为 24 而不是预期的 16。