#include "int128_ut_helpers.h" namespace NInt128Private { #if defined(_little_endian_) std::array GetAsArray(const ui128 value) { std::array result; const ui64 low = GetLow(value); const ui64 high = GetHigh(value); MemCopy(result.data(), reinterpret_cast(&low), sizeof(low)); MemCopy(result.data() + sizeof(low), reinterpret_cast(&high), sizeof(high)); return result; } std::array GetAsArray(const i128 value) { std::array result; const ui64 low = GetLow(value); const ui64 high = GetHigh(value); MemCopy(result.data(), reinterpret_cast(&low), sizeof(low)); MemCopy(result.data() + sizeof(low), reinterpret_cast(&high), sizeof(high)); return result; } #elif defined(_big_endian_) std::array GetAsArray(const i128 value) { std::array result; const ui64 low = GetLow(value); const ui64 high = GetHigh(value); MemCopy(result.data(), reinterpret_cast(&high), sizeof(high)); MemCopy(result.data() + sizeof(high), reinterpret_cast(&low), sizeof(low)); return result; } std::array GetAsArray(const ui128 value) { std::array result; const ui64 low = GetLow(value); const ui64 high = GetHigh(value); MemCopy(result.data(), reinterpret_cast(&high), sizeof(high)); MemCopy(result.data() + sizeof(high), reinterpret_cast(&low), sizeof(low)); return result; } #endif #if defined(Y_HAVE_INT128) std::array GetAsArray(const unsigned __int128 value) { std::array result; MemCopy(result.data(), reinterpret_cast(&value), sizeof(value)); return result; } std::array GetAsArray(const signed __int128 value) { std::array result; MemCopy(result.data(), reinterpret_cast(&value), sizeof(value)); return result; } #endif }