#include <xtd/console>
#include <xtd/double_object>
#include <xtd/environment>
#include <xtd/single_object>
#include <xtd/format>
enum class cap {title, middle, end};
template<typename number_t>
auto print_floating_point(const string& text, number_t value, cap c) {
if (c == cap::title)
console::out
<< "┌─────────────────────────────────────┬────────────┬──────────────────────────────────────────────────────────────────┐" << environment::new_line
<< "│ floating_point │ format │ representation │" << environment::new_line
<< "├─────────────────────────────────────┼────────────┼──────────────────────────────────────────────────────────────────┤" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {} │ " << format(
"{}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:b} │ " << format(
"{:b}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:B} │ " << format(
"{:B}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:c} │ " << format(
"{:c}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:C} │ " << format(
"{:C}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:e} │ " << format(
"{:e}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:E} │ " << format(
"{:E}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:f} │ " << format(
"{:f}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:F} │ " << format(
"{:F}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:g} │ " << format(
"{:g}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:G} │ " << format(
"{:G}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:n} │ " << format(
"{:n}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:N} │ " << format(
"{:N}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:p} │ " << format(
"{:p}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:P} │ " << format(
"{:P}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:x} │ " << format(
"{:x}", value).
pad_right(64) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(35) <<
" │ {:X} │ " << format(
"{:X}", value).
pad_right(64) <<
" │" << 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_floating_point(".0", .0, cap::title);
print_floating_point("12.345f", 12.345f, cap::middle);
print_floating_point("3.1415e-4", 3.1415e-4, cap::middle);
print_floating_point("double_object::positive_infinity", double_object::positive_infinity, cap::middle);
print_floating_point("single_object::negative_infinity", single_object::negative_infinity, cap::middle);
print_floating_point("double_object::NaN", double_object::NaN, cap::middle);
print_floating_point("single_object::min_value", single_object::min_value, cap::middle);
print_floating_point("double_object::max_value", double_object::max_value, cap::end);
}
basic_string pad_right(xtd::size total_width) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:1597
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10