mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-15 20:38:23 +01:00
feat: enhance LookupKey with const isnan method and comparison operator
This commit is contained in:
parent
521937a527
commit
6fb226887e
@ -21,7 +21,7 @@ struct Lookup_SC_notation {
|
||||
return {SC_NOTATION_EXPONENT_MASK, SC_NOTATION_SIGNIFICANT_MASK};
|
||||
}
|
||||
|
||||
constexpr bool isnan() {
|
||||
constexpr bool isnan() const {
|
||||
return !!(exp == SC_NOTATION_EXPONENT_MASK &&
|
||||
significant == SC_NOTATION_SIGNIFICANT_MASK);
|
||||
}
|
||||
@ -35,6 +35,10 @@ union Lookup_Keyelement {
|
||||
return std::memcmp(this, &other, sizeof(Lookup_Keyelement)) == 0 ? true
|
||||
: false;
|
||||
}
|
||||
|
||||
template <typename T> bool operator>(const T &other) const {
|
||||
return this->sc_notation.significant > other;
|
||||
}
|
||||
};
|
||||
|
||||
class LookupKey : public std::vector<Lookup_Keyelement> {
|
||||
|
||||
@ -65,6 +65,14 @@ public:
|
||||
std::uint32_t signif) {
|
||||
Lookup_Keyelement new_val = value;
|
||||
|
||||
if (value.sc_notation.isnan()) {
|
||||
return {.sc_notation = Lookup_SC_notation::nan()};
|
||||
}
|
||||
|
||||
if (signif == 0) {
|
||||
return {.sc_notation = {0, value > 0}};
|
||||
}
|
||||
|
||||
std::uint32_t diff_signif =
|
||||
static_cast<std::uint32_t>(
|
||||
std::ceil(std::log10(std::abs(value.sc_notation.significant)))) -
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user