xtd 0.2.0
sprintf_floating_point.cpp

Shows how to use xtd::string::sprintf method.

#include <xtd/console>
#include <xtd/environment>
#include <xtd/double_object>
#include <xtd/string>
using namespace xtd;
auto main() -> int {
console::out << string::sprintf("%f", 12.345) << environment::new_line;
console::out << string::sprintf("%F", 12.345) << environment::new_line;
console::out << string::sprintf("%e", 12.345) << environment::new_line;
console::out << string::sprintf("%E", 12.345) << environment::new_line;
console::out << string::sprintf("%g", 12.345) << environment::new_line;
console::out << string::sprintf("%G", 12.345) << environment::new_line;
console::out << string::sprintf("0x%a", 12.345) << environment::new_line;
console::out << string::sprintf("0x%A", 12.345) << environment::new_line;
}
// This code produces the following output :
//
// 12.345000
// 12.345000
// 1.234500e+01
// 1.234500E+01
// 12.345
// 12.345
// 0x0x1.8b0a3d70a3d71p+3
// 0x0X1.8B0A3D70A3D71P+3
// 4.94066E-324
// nan
// inf
// -inf
static constexpr double epsilon
Definition box_floating_point.hpp:56
static constexpr double NaN
Definition box_floating_point.hpp:59
static constexpr double positive_infinity
Definition box_floating_point.hpp:65
static constexpr double negative_infinity
Definition box_floating_point.hpp:62
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8