1 #ifndef OMEGA_H_INT128_HPP
2 #define OMEGA_H_INT128_HPP
8 #include <Omega_h_macros.h>
16 OMEGA_H_INLINE
Int128(std::int64_t h, std::uint64_t l);
17 OMEGA_H_INLINE
Int128(std::int64_t value);
20 double to_double(
double unit)
const;
21 void print(std::ostream& o)
const;
22 static OMEGA_H_INLINE
Int128 from_double(
double value,
double unit);
23 std::string to_string() {
24 std::ostringstream oss;
25 oss <<
"h: " << high <<
" l: " << low;
36 OMEGA_H_INLINE Int128::Int128(std::int64_t h, std::uint64_t l)
39 OMEGA_H_INLINE Int128::Int128(std::int64_t value)
40 : Int128(std::int64_t(-1) * (value < 0), std::uint64_t(value)) {}
42 OMEGA_H_INLINE Int128 Int128::from_double(
double value,
double unit) {
43 double normalized = value / unit;
44 return Int128(std::int64_t(normalized));
53 OMEGA_H_INLINE Int128 operator+(Int128 lhs, Int128 rhs) {
55 sum.high = lhs.high + rhs.high;
56 sum.low = lhs.low + rhs.low;
58 sum.high += (sum.low < lhs.low);
62 OMEGA_H_INLINE Int128 operator-(Int128 lhs, Int128 rhs) {
64 difference.high = lhs.high - rhs.high;
65 difference.low = lhs.low - rhs.low;
67 difference.high -= (difference.low > lhs.low);
71 OMEGA_H_INLINE Int128 operator-(Int128 x) {
return Int128(0) - x; }
73 OMEGA_H_INLINE Int128 operator>>(Int128 x,
int expo) {
75 shifted.low = (x.low >> expo) | (std::uint64_t(x.high) << (64 - expo));
76 shifted.high = x.high >> expo;
80 OMEGA_H_INLINE
bool operator==(Int128 lhs, Int128 rhs) {
81 return lhs.high == rhs.high && lhs.low == rhs.low;
84 OMEGA_H_INLINE
bool operator<(Int128 lhs, Int128 rhs) {
85 if (lhs.high != rhs.high)
return lhs.high < rhs.high;
86 return lhs.low < rhs.low;
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_int128.hpp:12