MCPcopy Create free account
hub / github.com/apache/impala / ConvertToInt256

Function ConvertToInt256

be/src/runtime/multi-precision.h:70–86  ·  view source on GitHub ↗

There is no implicit assignment from int128_t to int256_t (or in general, the boost multi precision types and __int128_t). TODO: look into the perf of this. I think the boost library is very slow with bitwise ops but reasonably fast with arithmetic ops so different implementations of this could have big perf differences.

Source from the content-addressed store, hash-verified

68/// ops but reasonably fast with arithmetic ops so different implementations of this
69/// could have big perf differences.
70inline int256_t ConvertToInt256(const int128_t& x) {
71 if (x < 0) {
72 uint64_t hi = static_cast<uint64_t>(-x >> 64);
73 uint64_t lo = static_cast<uint64_t>(-x);
74 int256_t v = hi;
75 v <<= 64;
76 v |= lo;
77 return -v;
78 } else {
79 uint64_t hi = static_cast<uint64_t>(x >> 64);
80 uint64_t lo = static_cast<uint64_t>(x);
81 int256_t v = hi;
82 v <<= 64;
83 v |= lo;
84 return v;
85 }
86}
87
88/// Converts an int256_t to an int128_t. int256_t does support convert_to<int128_t>() but
89/// that produces an approximate int128_t which makes it unusable.

Callers 6

TestScaleByFunction · 0.85
TESTFunction · 0.85
MultiplyMethod · 0.85
DivideMethod · 0.85
ModMethod · 0.85
CompareMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestScaleByFunction · 0.68
TESTFunction · 0.68