add SI prefixes
This commit is contained in:
parent
83ba1bae08
commit
9c094fb094
|
@ -23,6 +23,9 @@
|
|||
|
||||
using namespace std::string_literals;
|
||||
|
||||
using LitInt = unsigned long long int;
|
||||
using LitFlt = long double;
|
||||
|
||||
inline constexpr std::nullopt_t None{std::nullopt};
|
||||
|
||||
template<typename T>
|
||||
|
@ -72,6 +75,39 @@ struct IMemoryStream : public virtual MemoryStreamBuf, public std::istream {
|
|||
}
|
||||
};
|
||||
|
||||
#define siPrefixDivT(T, name, value) \
|
||||
constexpr T operator "" name(T n) {return n / T(value);}
|
||||
|
||||
#define siPrefixMulT(T, name, value) \
|
||||
constexpr T operator "" name(T n) {return n * T(value);}
|
||||
|
||||
#define siPrefixDiv(name, value) \
|
||||
siPrefixDivT(LitInt, name, value) \
|
||||
siPrefixDivT(LitFlt, name, value)
|
||||
|
||||
#define siPrefixMul(name, value) \
|
||||
siPrefixMulT(LitInt, name, value) \
|
||||
siPrefixMulT(LitFlt, name, value)
|
||||
|
||||
#define siPrefixDivMul(divName, mulName, value) \
|
||||
siPrefixDiv(divName, value) \
|
||||
siPrefixMul(mulName, value)
|
||||
|
||||
siPrefixDivMul(_d, _da, 10)
|
||||
siPrefixDivMul(_c, _h, 100)
|
||||
siPrefixDivMul(_m, _k, 1'000)
|
||||
siPrefixDivMul(_mc, _M, 1'000'000)
|
||||
siPrefixDivMul(_n, _G, 1'000'000'000)
|
||||
siPrefixDivMul(_p, _T, 1'000'000'000'000)
|
||||
siPrefixDivMul(_f, _P, 1'000'000'000'000'000)
|
||||
siPrefixDivMul(_a, _E, 1'000'000'000'000'000'000)
|
||||
siPrefixMul(_Ki, 1'024)
|
||||
siPrefixMul(_Mi, 1'048'576)
|
||||
siPrefixMul(_Gi, 1'073'741'824)
|
||||
siPrefixMul(_Ti, 1'099'511'627'776)
|
||||
siPrefixMul(_Pi, 1'125'899'906'842'624)
|
||||
siPrefixMul(_Ei, 1'152'921'504'606'846'976)
|
||||
|
||||
static inline QString trMain(char const *sourceText,
|
||||
char const *disambiguation = nullptr,
|
||||
int n = -1) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user