MCPcopy Create free account
hub / github.com/DFHack/dfhack / get_magnitude

Function get_magnitude

library/MiscUtils.cpp:128–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127template<typename T>
128static int get_magnitude(T absnum) {
129 static const size_t max_magnitude = sig_fig_db.size() - 1;
130 if (absnum <= 1)
131 return 0;
132 return std::min(max_magnitude, (size_t)std::floor(std::log2(absnum) * (1/std::log2(10))) + 1);
133}
134
135DFHACK_EXPORT std::string format_number_by_sig_fig(double num, size_t sig_figs) {
136 if (num == 0)

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected