36#if defined( _MSC_VER )
39#include <__msvc_int128.hpp>
48 const bool negative = aHi < 0;
49 uint64_t hi =
static_cast<uint64_t
>( aHi );
55 hi = ~hi + ( lo == 0 ? 1 : 0 );
62 magnitude =
static_cast<double>( lo );
68 int shift = std::countl_zero( hi );
69 uint64_t
top = shift == 0 ? hi : ( hi << shift ) | ( lo >> ( 64 - shift ) );
71 if( ( lo << shift ) != 0 )
74 magnitude = std::ldexp(
static_cast<double>(
top ), 64 - shift );
77 return negative ? -magnitude : magnitude;
82#if defined( _MSC_VER )
96 return static_cast<double>( aValue );
double WordsToDouble(int64_t aHi, uint64_t aLo)
Nearest double to hi * 2^64 + lo, ties to even.
KIBIS top(path, &reporter)
VECTOR2< int64_t > VECTOR2L
unsigned __int128 KI_UINT128
constexpr KI_INT128 DotWide(const VECTOR2L &aA, const VECTOR2L &aB)
Exact aA.x * aB.x + aA.y * aB.y.
double ToDouble(KI_INT128 aValue)
constexpr KI_INT128 CrossWide(const VECTOR2L &aA, const VECTOR2L &aB)
Exact aA.x * aB.y - aA.y * aB.x.