diff --git a/libs/pbd/pbd/int62.h b/libs/pbd/pbd/int62.h index aa31e8afb3..490312384f 100644 --- a/libs/pbd/pbd/int62.h +++ b/libs/pbd/pbd/int62.h @@ -71,12 +71,19 @@ class alignas(16) int62_t { int62_t& operator= (int62_t const & other) { v.store (other.v.load()); return *this; } int62_t operator- () const { int64_t tmp = v; return int62_t (flagged (tmp), -int62(tmp)); } + int62_t operator+ (int n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) + n); } int62_t operator- (int n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) - n); } int62_t operator* (int n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) * n); } int62_t operator/ (int n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) / n); } int62_t operator% (int n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) % n); } + int62_t operator+ (int62_t n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) + n); } + int62_t operator- (int62_t n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) - n); } + int62_t operator* (int62_t n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) * n); } + int62_t operator/ (int62_t n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) / n); } + int62_t operator% (int62_t n) const { int64_t tmp = v; return int62_t (flagged (tmp), int62 (tmp) % n); } + /* comparison operators .. will throw if the two objects have different * flag settings (which is assumed to indicate that they differ in some * important respect, and thus should not have their values compared) @@ -96,6 +103,8 @@ class alignas(16) int62_t { operator int64_t() const { return int62(v); } + int62_t abs() const { int64_t tmp = v; return int62_t (flagged(tmp), ::abs(int62(tmp))); } + int62_t& operator+= (int64_t n) { while (1) { int64_t oldval (v);