Skip to content

Commit

Permalink
radix digits and base10
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgerrets committed Feb 28, 2024
1 parent f0b0098 commit 06a9f49
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/include/duckdb/common/limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct NumericLimits {
return std::is_signed<T>::value;
}
DUCKDB_API static constexpr idx_t Digits() {
return std::numeric_limits<T>::digits10;
}
DUCKDB_API static constexpr idx_t Radix() {
return std::numeric_limits<T>::digits;
}
};
Expand All @@ -41,34 +44,38 @@ template <>
struct NumericLimits<hugeint_t> {
static constexpr hugeint_t Minimum() {
return {std::numeric_limits<int64_t>::lowest(), 0};
};
}
static constexpr hugeint_t Maximum() {
return {std::numeric_limits<int64_t>::max(), std::numeric_limits<uint64_t>::max()};
};
}
static constexpr bool IsSigned() {
return true;
}

static constexpr idx_t Digits() {
return 39;
}
static constexpr idx_t Radix() {
return 127;
}
};

template <>
struct NumericLimits<uhugeint_t> {
static constexpr uhugeint_t Minimum() {
return {0, 0};
};
}
static constexpr uhugeint_t Maximum() {
return {std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max()};
};
}
static constexpr bool IsSigned() {
return false;
}

static constexpr idx_t Digits() {
return 39;
}
static constexpr idx_t Radix() {
return 128;
}
};

template <>
Expand Down

0 comments on commit 06a9f49

Please sign in to comment.