xtd 0.2.0
bit_converter.cpp

Shows how to use xtd::bit_converter class.

#include <xtd/bit_converter>
#include <xtd/console>
using namespace xtd;
auto main() -> int {
const auto formatter = "{0,25}{1,30}";
auto a_double = 0.1111111111111111111;
auto a_single = 0.1111111111111111111f;
auto a_long = 1111111111111111111_s64;
auto an_int = 1111111111;
auto a_short = 11111_u16;
auto a_char = '*';
auto a_bool = true;
console::write_line("This example of methods of the BitConverter class"
"\ngenerates the following output.\n");
console::write_line(formatter, "argument", "byte array");
console::write_line(formatter, "--------", "----------");
// Convert values to Byte arrays and display them.
}
// This code produces the following output :
//
// This example of methods of the BitConverter class
// generates the following output.
//
// argument byte array
// -------- ----------
// 0.111111111111111 1C-C7-71-1C-C7-71-BC-3F
// 0.1111111 39-8E-E3-3D
// 1111111111111111111 C7-71-C4-2B-AB-75-6B-0F
// 1111111111 C7-35-3A-42
// 11111 67-2B
// * 2A-00-00-00
// True 01
static xtd::string to_string(const xtd::array< xtd::byte > &value)
Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexad...
static xtd::array< xtd::byte > get_bytes(bool value) noexcept
Returns the specified Boolean value as an xtd::array of bytes.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Provides the base class to format any object.
Definition formatter.hpp:28