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

Function format_number

library/include/MiscUtils.h:506–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504// format a number according to the give formatting type
505template<typename T>
506static inline std::string format_number(T num, NumberFormatType type) {
507 std::ostringstream ss;
508 imbue_with_locale(ss, type);
509 switch (type) {
510 case NumberFormatType::SCIENTIFIC:
511 ss << (double)num;
512 break;
513 case NumberFormatType::SIG_FIG:
514 ss << format_number_by_sig_fig(num, 3);
515 break;
516 default:
517 ss << num;
518 break;
519 }
520 return ss.str();
521}
522
523template<typename T>
524static inline std::string format_number(T num) {

Callers 2

formatIntFunction · 0.85
formatFloatFunction · 0.85

Calls 2

imbue_with_localeFunction · 0.85
strMethod · 0.45

Tested by

no test coverage detected