#include <xtd/console>
#include <xtd/environment>
#include <xtd/string>
enum class cap { title, middle, end };
void print_number(string text, int value, cap c) {
if (c == cap::title)
console::out << "┌───────────┬────────────┬──────────────────────────────────┐" << environment::new_line
<< "│ number │ format │ representation │" << environment::new_line
<< "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {} │ " << string::format("{}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:b} │ " << string::format("{:b}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:b32} │ " << string::format("{:b32}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:B} │ " << string::format("{:B}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:B32} │ " << string::format("{:B32}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:c} │ " << string::format("{:c}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:C} │ " << string::format("{:C}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:d} │ " << string::format("{:d}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:d16} │ " << string::format("{:d16}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:D} │ " << string::format("{:D}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:D16} │ " << string::format("{:D16}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:e} │ " << string::format("{:e}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:E} │ " << string::format("{:E}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:f} │ " << string::format("{:f}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:f4} │ " << string::format("{:f4}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:F} │ " << string::format("{:F}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:F4} │ " << string::format("{:F4}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:g} │ " << string::format("{:g}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:G} │ " << string::format("{:G}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:o} │ " << string::format("{:o}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:o16} │ " << string::format("{:o16}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:O} │ " << string::format("{:O}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:O16} │ " << string::format("{:O16}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:n} │ " << string::format("{:n}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:N} │ " << string::format("{:N}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:p} │ " << string::format("{:p}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:P} │ " << string::format("{:P}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:x} │ " << string::format("{:x}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:x16} │ " << string::format("{:x16}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:X} │ " << string::format("{:X}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:X16} │ " << string::format("{:X16}", value).pad_right(32) << " |" << environment::new_line;
if (c != cap::end)
console::out << "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
else
console::out << "└───────────┴────────────┴──────────────────────────────────┘" << environment::new_line;
}
auto main() -> int {
std::locale::global(std::locale {"en_US.UTF-8"});
print_number("0", 0, cap::title);
print_number("42", 42, cap::middle);
print_number("123456789", 123456789, cap::end);
}
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10