xtd 1.0.0
Loading...
Searching...
No Matches
xtd::bit_converter Class Referencefinal
Inheritance diagram for xtd::bit_converter:
xtd::static_object

Definition

Converts base data types to an xtd::array of bytes, and an xtd::array of bytes to base data types.

Header
#include <xtd/bit_converter>
Namespace
xtd
Library
xtd.core
Remarks
The xtd::bit_converter class helps manipulate value types in their fundamental form, as a series of bytes. A xtd::byte is defined as an 8-bit unsigned integer. The xtd::bit_converter class includes static methods to convert each of the primitive types to and from an xtd::array of bytes, as the following table illustrates.
Type To xtd::byte conversion From xtd::byte conversion
bool xtd::bit_converter::get_bytes(bool) xtd::bit_converter::to_boolean(const xtd::array< xtd::byte >&, xtd::usize)
char32 xtd::bit_converter::get_bytes(char32) xtd::bit_converter::to_char(const xtd::array< xtd::byte >&, xtd::usize)
double xtd::bit_converter::get_bytes(double) - or - double_to_int64_bits(double) xtd::bit_converter::to_double(const xtd::array< xtd::byte >&, xtd::usize) - or - int64_bits_to_double(int64)
int16 xtd::bit_converter::get_bytes(int16) xtd::bit_converter::to_int16(const xtd::array< xtd::byte >&, xtd::usize)
int32 xtd::bit_converter::get_bytes(int32) xtd::bit_converter::to_int32(const xtd::array< xtd::byte >&, xtd::usize)
int64 xtd::bit_converter::get_bytes(int64) xtd::bit_converter::to_int64(const xtd::array< xtd::byte >&, xtd::usize)
float xtd::bit_converter::get_bytes(float) - or - single_to_int32_bits(float) xtd::bit_converter::to_single(const xtd::array< xtd::byte >&, xtd::usize) - or - int32_bits_to_single(int32)
uint16. xtd::bit_converter::get_bytes(uint16) xtd::bit_converter::to_uint16(const xtd::array< xtd::byte >&, xtd::usize)
uint32 xtd::bit_converter::get_bytes(uint32) xtd::bit_converter::to_uint32(const xtd::array< xtd::byte >&, xtd::usize)
uint64 xtd::bit_converter::get_bytes(uint64) xtd::bit_converter::to_uint64(const xtd::array< xtd::byte >&, xtd::usize)
If you use bit_converter methods to round-trip data, make sure that the xtd::bit_converter::get_bytes overload and the to_<type> method specify the same type. As the following example illustrates, restoring an xtd::array that represents a signed integer by calling the xtd::bit_converter::to_uint32 method can result in a value that is different from the original.
#include <xtd/xtd>
namespace bit_converter_round_trips_example {
class program {
public:
// The main entry point for the application.
static auto main() {
auto value = -16;
auto bytes = bit_converter::get_bytes(value);
// Convert bytes back to int.
auto int_value = bit_converter::to_int32(bytes, 0);
console::write_line("{0} = {1}: {2}", value, int_value, value == int_value ? "Round-trips" : "Does not round-trip");
// Convert bytes to unsigned int.
auto uint_value = bit_converter::to_uint32(bytes, 0);
console::write_line("{0} = {1}: {2}", value, uint_value, static_cast<uint32>(value) == uint_value ? "Round-trips" : "Does not round-trip");
}
};
}
startup_(bit_converter_round_trips_example::program::main);
// This code produces the following output :
//
// -16 = -16: Round-trips
// -16 = 4294967280: Round-trip
static auto get_bytes(bool value) noexcept -> xtd::array< xtd::byte >
Returns the specified Boolean value as an xtd::array of bytes.
static auto to_uint32(const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::uint32
Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::...
static auto to_int32(const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::int32
Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::...
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:152
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
The order of bytes in the xtd::array returned by the xtd::bit_converter::get_bytes method overloads (as well as the order of bits in the integer returned by the xtd::bit_converter:double_to_int64_bits method and the order of hexadecimal strings returned by the to_string(xtd::byte[]) method) depends on whether the computer architecture is little-endian or big-endian. Similarly, the order of bytes in the xtd::array and returned by the ToIntegerValue methods and the to_char method depends on whether the computer architecture is little-endian or big-endian. The endianness of an architecture is indicated by the is_little_endian property, which returns true on little-endian systems and false on big-endian systems. On little-endian systems, lower-order bytes precede higher-order bytes. On big-endian system, higher-order bytes precede lower-order bytes. The following table illustrates the difference in the xtd::byte xtd::arrays that result from passing the integer 1,234,567,890 (0x499602D2) to the get_bytes(int32) method. The bytes are listed in order from the xtd::byte at index 0 to the xtd::byte at index 3.
Little-endian D2-02-96-49
Big-endian 49-96-02-D2
Because the return value of some methods depends on system architecture, be careful when transmitting xtd::byte data beyond machine boundaries:
  • If all systems sending and receiving data are guaranteed to have the same endianness, nothing has be done to the data.
  • If systems sending and receiving data can have different endianness, always transmit data in a particular order. This means that the order of bytes in the xtd::array may have to be reversed either before sending them or after receiving them. A common convention is to transmit data in network xtd::byte order (big-endian order). The following example provides an implementation for sending an integer value in network xtd::byte order.
  • If systems sending and receiving data can have different endianness and the data to be transmitted consists of signed integers, call the IPAddress.HostToNetworkOrder method to convert the data to network xtd::byte order and the IPAddress.NetworkToHostOrder method to convert it to the order required by the recipient.
Examples
The following code example illustrates the use of several bit_converter class methods.
#include <xtd/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 bit_converter 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 bit_converter 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 auto to_string(const xtd::array< xtd::byte > &value) -> xtd::string
Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexad...
Provides the base class to format any object.
Definition formatter.hpp:28

Public Types

enum class  endian {
  little ,
  big
}
 Represents the xtd::byte order ("endianness") in which data is stored in this computer architecture. More...

Public Fields

static constexpr bool is_big_endian
 Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.
static constexpr bool is_little_endian
 Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.
static constexpr endian endianness
 Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.

Public Static Methods

static auto double_to_int64_bits (double value) noexcept -> xtd::int64
 Converts the specified double-precision floating point number to a 64-bit signed integer.
static auto get_bytes (bool value) noexcept -> xtd::array< xtd::byte >
 Returns the specified Boolean value as an xtd::array of bytes.
static auto get_bytes (char value) noexcept -> xtd::array< xtd::byte >
 Returns the specified char value as an xtd::array of bytes.
static auto get_bytes (char8 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified xtd::char8 value as an xtd::array of bytes.
static auto get_bytes (char16 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified xtd::char16 value as an xtd::array of bytes.
static auto get_bytes (char32 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified xtd::char32 value as an xtd::array of bytes.
static auto get_bytes (wchar value) noexcept -> xtd::array< xtd::byte >
 Returns the specified wchar value as an xtd::array of bytes.
static auto get_bytes (double value) noexcept -> xtd::array< xtd::byte >
 Returns the specified double value as an xtd::array of bytes.
static auto get_bytes (sbyte value) noexcept -> xtd::array< xtd::byte >
 Returns the specified xtd::byte value as an xtd::array of bytes.
static auto get_bytes (int16 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified int16 value as an xtd::array of bytes.
static auto get_bytes (int32 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified int32 value as an xtd::array of bytes.
static auto get_bytes (int64 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified int64 value as an xtd::array of bytes.
static auto get_bytes (float value) noexcept -> xtd::array< xtd::byte >
 Returns the specified single value as an xtd::array of bytes.
static auto get_bytes (xtd::byte value) noexcept -> xtd::array< xtd::byte >
 Returns the specified xtd::byte value as an xtd::array of bytes.
static auto get_bytes (uint16 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified uint16 value as an xtd::array of bytes.
static auto get_bytes (uint32 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified uint32 value as an xtd::array of bytes.
static auto get_bytes (uint64 value) noexcept -> xtd::array< xtd::byte >
 Returns the specified uint64 value as an xtd::array of bytes.
static auto int32_bits_to_single (int32 value) noexcept -> xtd::single
 Converts the specified 32-bit signed integer to a single-precision floating point number.
static auto int64_bits_to_double (int64 value) noexcept -> double
 Converts the specified 64-bit signed integer to a double-precision floating point number.
static auto single_to_int32_bits (float value) noexcept -> xtd::int32
 Converts the specified single-precision floating point number to a 32-bit signed integer.
static auto to_boolean (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> bool
 Returns a Boolean value converted from one xtd::byte at a specified position in a xtd::byte xtd::array.
static auto to_boolean (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> bool
 Returns a Boolean value converted from one xtd::byte at a specified position in a xtd::byte xtd::read_only_span.
static auto to_char (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::char32
 Returns a char32 converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_char (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::char32
 Returns a char32 converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_double (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> double
 Returns a double-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::array.
static auto to_double (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> double
 Returns a double-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_int16 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::int16
 Returns a 16-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_int16 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::int16
 Returns a 16-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_int32 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::int32
 Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_int32 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::int32
 Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_int64 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::int64
 Returns a 64-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_int64 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::int64
 Returns a 64-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_single (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::single
 Returns a single-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::array.
static auto to_single (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::single
 Returns a single-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_uint16 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::uint16
 Returns a 16-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_uint16 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::uint16
 Returns a 16-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_uint32 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::uint32
 Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_uint32 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::uint32
 Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_uint64 (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::uint64
 Returns a 64-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_uint64 (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::uint64
 Returns a 64-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_size (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::usize
 Returns a xtd::usize converted from two bytes at a specified position in a xtd::byte xtd::array.
static auto to_size (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::usize
 Returns a sxtd::ize converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.
static auto to_string (const xtd::array< xtd::byte > &value) -> xtd::string
 Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexadecimal xtd::string representation.
static auto to_string (const read_only_span< xtd::byte > &value) -> xtd::string
 Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexadecimal xtd::string representation.
static auto to_string (const xtd::array< xtd::byte > &value, xtd::usize start_index) -> xtd::string
 Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.
static auto to_string (const read_only_span< xtd::byte > &value, xtd::usize start_index) -> xtd::string
 Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.
static auto to_string (const xtd::array< xtd::byte > &value, xtd::usize start_index, xtd::usize length) -> xtd::string
 Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.
static auto to_string (const read_only_span< xtd::byte > &value, xtd::usize start_index, xtd::usize length) -> xtd::string
 Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Member Enumeration Documentation

◆ endian

enum class xtd::bit_converter::endian
strong

Represents the xtd::byte order ("endianness") in which data is stored in this computer architecture.

Remarks
Different computer architectures store data using different xtd::byte orders. "Big-endian" means the most significant xtd::byte is on the left end of a word. "Little-endian" means the most significant xtd::byte is on the right end of a word.
Enumerator
little 

Represnets "Little-endian" order.

big 

Represnets "Big-endian" order.

Member Function Documentation

◆ double_to_int64_bits()

auto xtd::bit_converter::double_to_int64_bits ( double value) -> xtd::int64
staticnodiscardnoexcept

Converts the specified double-precision floating point number to a 64-bit signed integer.

Parameters
valueThe number to convert.
Returns
A 64-bit signed integer whose value is equivalent to value.
Remarks
The order of bits in the integer returned by the double_to_int64_bits method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts the bit patterns of several Double values to int64 values with the double_to_int64_bits method.

◆ get_bytes() [1/16]

auto xtd::bit_converter::get_bytes ( bool value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified Boolean value as an xtd::array of bytes.

Parameters
valueA Boolean value.
Returns
An xtd::array of bytes with length 1.
Examples
The following code example converts the bit patterns of Boolean values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [2/16]

auto xtd::bit_converter::get_bytes ( char value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified char value as an xtd::array of bytes.

Parameters
valueA char value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of char values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [3/16]

auto xtd::bit_converter::get_bytes ( char8 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified xtd::char8 value as an xtd::array of bytes.

Parameters
valueA xtd::char8 value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of char values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [4/16]

auto xtd::bit_converter::get_bytes ( char16 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified xtd::char16 value as an xtd::array of bytes.

Parameters
valueA xtd::char16 value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of xtd::char16 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [5/16]

auto xtd::bit_converter::get_bytes ( char32 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified xtd::char32 value as an xtd::array of bytes.

Parameters
valueA xtd::char32 value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of xtd::char32 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [6/16]

auto xtd::bit_converter::get_bytes ( wchar value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified wchar value as an xtd::array of bytes.

Parameters
valueA wchar value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of wchar values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [7/16]

auto xtd::bit_converter::get_bytes ( double value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified double value as an xtd::array of bytes.

Parameters
valueA double value.
Returns
An xtd::array of bytes with length 8.
Examples
The following code example converts the bit patterns of double values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [8/16]

auto xtd::bit_converter::get_bytes ( sbyte value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified xtd::byte value as an xtd::array of bytes.

Parameters
valueA xtd::byte value.
Returns
An xtd::array of bytes with length 1.

◆ get_bytes() [9/16]

auto xtd::bit_converter::get_bytes ( int16 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified int16 value as an xtd::array of bytes.

Parameters
valueA int16 value.
Returns
An xtd::array of bytes with length 2.
Examples
The following code example converts the bit patterns of int16 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [10/16]

auto xtd::bit_converter::get_bytes ( int32 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified int32 value as an xtd::array of bytes.

Parameters
valueA int32 value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of int32 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [11/16]

auto xtd::bit_converter::get_bytes ( int64 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified int64 value as an xtd::array of bytes.

Parameters
valueA int64 value.
Returns
An xtd::array of bytes with length 8.
Examples
The following code example converts the bit patterns of int64 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [12/16]

auto xtd::bit_converter::get_bytes ( float value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified single value as an xtd::array of bytes.

Parameters
valueA single value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of single values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [13/16]

auto xtd::bit_converter::get_bytes ( xtd::byte value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified xtd::byte value as an xtd::array of bytes.

Parameters
valueA xtd::byte value.
Returns
An xtd::array of bytes with length 1.

◆ get_bytes() [14/16]

auto xtd::bit_converter::get_bytes ( uint16 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified uint16 value as an xtd::array of bytes.

Parameters
valueA uint16 value.
Returns
An xtd::array of bytes with length 2.
Examples
The following code example converts the bit patterns of uint16 values to xtd::byte xtd::arrays with the get_bytes method.

◆ get_bytes() [15/16]

auto xtd::bit_converter::get_bytes ( uint32 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified uint32 value as an xtd::array of bytes.

Parameters
valueA uint32 value.
Returns
An xtd::array of bytes with length 4.
Examples
The following code example converts the bit patterns of uint32 values to xtd::byte xtd::arrays with the get_bytes method.
;

◆ get_bytes() [16/16]

auto xtd::bit_converter::get_bytes ( uint64 value) -> xtd::array< xtd::byte >
staticnodiscardnoexcept

Returns the specified uint64 value as an xtd::array of bytes.

Parameters
valueA uint64 value.
Returns
An xtd::array of bytes with length 8.
Examples
The following code example converts the bit patterns of uint64 values to xtd::byte xtd::arrays with the get_bytes method.

◆ int32_bits_to_single()

auto xtd::bit_converter::int32_bits_to_single ( int32 value) -> xtd::single
staticnodiscardnoexcept

Converts the specified 32-bit signed integer to a single-precision floating point number.

Parameters
valueThe number to convert.
Returns
A single-precision floating point number whose value is equivalent to value.
Remarks
Typically, value is an integer that is returned by the single_to_int32_bits method.

◆ int64_bits_to_double()

auto xtd::bit_converter::int64_bits_to_double ( int64 value) -> double
staticnodiscardnoexcept

Converts the specified 64-bit signed integer to a double-precision floating point number.

Parameters
valueThe number to convert.
Returns
A double-precision floating point number whose value is equivalent to value.
Remarks
Typically, value is an integer that is returned by the double_to_int64_bits method.

◆ single_to_int32_bits()

auto xtd::bit_converter::single_to_int32_bits ( float value) -> xtd::int32
staticnodiscardnoexcept

Converts the specified single-precision floating point number to a 32-bit signed integer.

Parameters
valueThe number to convert.
Returns
A 32-bit signed integer whose value is equivalent to value.
Remarks
The order of bits in the integer returned by the double_to_int64_bits method depends on whether the computer architecture is little-endian or big-endian.

◆ to_boolean() [1/2]

auto xtd::bit_converter::to_boolean ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> bool
staticnodiscard

Returns a Boolean value converted from one xtd::byte at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
bool true if the xtd::byte at start_index in value is nonzero; otherwise, false.
Exceptions
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Examples
The following code example converts elements of xtd::byte xtd::arrays to Boolean values with the to_boolean method.

◆ to_boolean() [2/2]

auto xtd::bit_converter::to_boolean ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> bool
staticnodiscard

Returns a Boolean value converted from one xtd::byte at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
bool true if the xtd::byte at start_index in value is nonzero; otherwise, false.
Exceptions
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Examples
The following code example converts elements of xtd::byte xtd::arrays to Boolean values with the to_boolean method.

◆ to_char() [1/2]

auto xtd::bit_converter::to_char ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::char32
staticnodiscard

Returns a char32 converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A char32 formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_char method converts the bytes from index start_index to start_index + 3 to an xtd::int32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_char() [2/2]

auto xtd::bit_converter::to_char ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::char32
staticnodiscard

Returns a char32 converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A char32 formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_char method converts the bytes from index start_index to start_index + 3 to an xtd::int32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_double() [1/2]

auto xtd::bit_converter::to_double ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> double
staticnodiscard

Returns a double-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A double precision floating point number formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_double method converts the bytes from index start_index to start_index + 7 to a Double value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_double() [2/2]

auto xtd::bit_converter::to_double ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> double
staticnodiscard

Returns a double-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A double precision floating point number formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_double method converts the bytes from index start_index to start_index + 7 to a Double value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int16() [1/2]

auto xtd::bit_converter::to_int16 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int16
staticnodiscard

Returns a 16-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 16-bit signed integer formed by two bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int16 method converts the bytes from index start_index to start_index + 1 to an xtd::int16 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int16() [2/2]

auto xtd::bit_converter::to_int16 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int16
staticnodiscard

Returns a 16-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 16-bit signed integer formed by two bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int16 method converts the bytes from index start_index to start_index + 1 to an xtd::int16 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int32() [1/2]

auto xtd::bit_converter::to_int32 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int32
staticnodiscard

Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 32-bit signed integer formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int32 method converts the bytes from index start_index to start_index + 3 to an xtd::int32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int32() [2/2]

auto xtd::bit_converter::to_int32 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int32
staticnodiscard

Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 32-bit signed integer formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int32 method converts the bytes from index start_index to start_index + 3 to an xtd::int32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int64() [1/2]

auto xtd::bit_converter::to_int64 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int64
staticnodiscard

Returns a 64-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 64-bit signed integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int64 method converts the bytes from index start_index to start_index + 7 to an xtd::int64 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_int64() [2/2]

auto xtd::bit_converter::to_int64 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::int64
staticnodiscard

Returns a 64-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 64-bit signed integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_int64 method converts the bytes from index start_index to start_index + 7 to an xtd::int64 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_single() [1/2]

auto xtd::bit_converter::to_single ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::single
staticnodiscard

Returns a single-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A single precision floating point number formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_single method converts the bytes from index start_index to start_index + 3 to a Double value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_single() [2/2]

auto xtd::bit_converter::to_single ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::single
staticnodiscard

Returns a single-precision floating point number converted from eight bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A single precision floating point number formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_single method converts the bytes from index start_index to start_index + 3 to a Double value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint16() [1/2]

auto xtd::bit_converter::to_uint16 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint16
staticnodiscard

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 16-bit unsigned integer formed by two bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint16 method converts the bytes from index start_index to start_index + 1 to an xtd::uint16 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint16() [2/2]

auto xtd::bit_converter::to_uint16 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint16
staticnodiscard

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 16-bit unsigned integer formed by two bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint16 method converts the bytes from index start_index to start_index + 1 to an xtd::uint16 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint32() [1/2]

auto xtd::bit_converter::to_uint32 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint32
staticnodiscard

Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 32-bit signed integer formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint32 method converts the bytes from index start_index to start_index + 3 to an xtd::uint32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint32() [2/2]

auto xtd::bit_converter::to_uint32 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint32
staticnodiscard

Returns a 32-bit signed integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 32-bit signed integer formed by four bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint32 method converts the bytes from index start_index to start_index + 3 to an xtd::uint32 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint64() [1/2]

auto xtd::bit_converter::to_uint64 ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint64
staticnodiscard

Returns a 64-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 64-bit unsigned integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint64 method converts the bytes from index start_index to start_index + 7 to an xtd::uint64 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_uint64() [2/2]

auto xtd::bit_converter::to_uint64 ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::uint64
staticnodiscard

Returns a 64-bit unsigned integer converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 64-bit unsigned integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint64 method converts the bytes from index start_index to start_index + 7 to an xtd::uint64 value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_size() [1/2]

auto xtd::bit_converter::to_size ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::usize
staticnodiscard

Returns a xtd::usize converted from two bytes at a specified position in a xtd::byte xtd::array.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
A 64-bit unsigned integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_uint64to_sizemethod converts the bytes from index start_index to start_index + 7 to an xtd::usize value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_size() [2/2]

auto xtd::bit_converter::to_size ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::usize
staticnodiscard

Returns a sxtd::ize converted from two bytes at a specified position in a xtd::byte xtd::read_only_span.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
A 64-bit unsigned integer formed by eight bytes beginning at start_index.
Exceptions
argument_exceptionstart_index equals the length of value minus 1.
argument_null_exceptionvalue is null
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The to_size method converts the bytes from index start_index to start_index + 7 to an xtd::usize value. The order of bytes in the xtd::array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of the bit_converter class topic.

◆ to_string() [1/6]

auto xtd::bit_converter::to_string ( const xtd::array< xtd::byte > & value) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::array of bytes.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
Remarks
All the elements of value are converted. The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// The main entry point for the application.
static auto main() {
array<byte> array_one = {0, 1, 2, 4, 8, 16, 32, 64, 128, 255};
array<byte> array_two = {32, 0, 0, 42, 0, 65, 0, 125, 0, 197, 0, 168, 3, 41, 4, 172, 32};
array<byte> array_three = {15, 0, 0, 128, 16, 39, 240, 216, 241, 255, 127};
array<byte> array_four = {15, 0, 0, 0, 0, 16, 0, 255, 3, 0, 0, 202, 154, 59, 255, 255, 255, 255, 127};
console::write_line("This example of the xtd::bit_converter::to_string(const xtd::array<xtd::byte>&) \n"
"method generates the following output.\n");
write_byte_array(array_one, "array_one");
write_byte_array(array_two, "array_two");
write_byte_array(array_three, "array_three");
write_byte_array(array_four, "array_four");
}
private:
// Display a byte array with a name.
static void write_byte_array(const array<byte>& bytes, const string& name) {
string under_line = "--------------------------------";
console::write_line(name);
console::write_line(under_line.substring(0, math::min(name.length(), under_line.length())));
console::write_line(bit_converter::to_string(bytes));
console::write_line();
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the xtd::bit_converter::to_string(const xtd::array<xtd::byte>&)
// method generates the following output.
//
// array_one
// ---------
// 00-01-02-04-08-10-20-40-80-FF
//
// array_two
// ---------
// 20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
//
// array_three
// -----------
// 0F-00-00-80-10-27-F0-D8-F1-FF-7F
//
// array_four
// ----------
// 0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
//
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
auto name() noexcept -> xtd::string
Gets the thread name of the current thread.

◆ to_string() [2/6]

auto xtd::bit_converter::to_string ( const read_only_span< xtd::byte > & value) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::read_only_span of bytes.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
Remarks
All the elements of value are converted. The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// The main entry point for the application.
static auto main() {
array<byte> array_one = {0, 1, 2, 4, 8, 16, 32, 64, 128, 255};
array<byte> array_two = {32, 0, 0, 42, 0, 65, 0, 125, 0, 197, 0, 168, 3, 41, 4, 172, 32};
array<byte> array_three = {15, 0, 0, 128, 16, 39, 240, 216, 241, 255, 127};
array<byte> array_four = {15, 0, 0, 0, 0, 16, 0, 255, 3, 0, 0, 202, 154, 59, 255, 255, 255, 255, 127};
console::write_line("This example of the xtd::bit_converter::to_string(const xtd::read_only_span<xtd::byte>&) \n"
"method generates the following output.\n");
write_byte_array(array_one, "array_one");
write_byte_array(array_two, "array_two");
write_byte_array(array_three, "array_three");
write_byte_array(array_four, "array_four");
}
private:
// Display a byte array with a name.
static void write_byte_array(const read_only_span<byte>& bytes, const string& name) {
string under_line = "--------------------------------";
console::write_line(name);
console::write_line(under_line.substring(0, math::min(name.length(), under_line.length())));
console::write_line(bit_converter::to_string(bytes));
console::write_line();
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the xtd::bit_converter::to_string(const xtd::read_only_span<xtd::byte>&)
// method generates the following output.
//
// array_one
// ---------
// 00-01-02-04-08-10-20-40-80-FF
//
// array_two
// ---------
// 20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20
//
// array_three
// -----------
// 0F-00-00-80-10-27-F0-D8-F1-FF-7F
//
// array_four
// ----------
// 0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F
//

◆ to_string() [3/6]

auto xtd::bit_converter::to_string ( const xtd::array< xtd::byte > & value,
xtd::usize start_index ) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The elements from xtd::array position start_index to the end of the xtd::array are converted. The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// Display a byte array, using multiple lines if necessary.
static void write_multi_line_byte_array(const array<byte>& bytes, const string& name) {
const auto row_size = 20_z;
const auto underLine = "--------------------------------"_s;
auto iter = 0_z;
console::write_line(underLine.substring(0, math::min(name.length(), underLine.length())));
for(iter = 0; iter < bytes.length() - row_size; iter += row_size) {
console::write(bit_converter::to_string(bytes, iter, row_size));
}
}
// The main entry point for the application.
static auto main() {
auto array_one = array<byte> {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127
};
auto array_two = array<byte> {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129
};
auto array_three = array<byte> {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157
};
console::write_line("This example of the\n"
" xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and\n"
" xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)\n"
"methods generates the following output.\n");
write_multi_line_byte_array(array_one, "array_one");
write_multi_line_byte_array(array_two, "array_two");
write_multi_line_byte_array(array_three, "array_three");
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)
// methods generates the following output.
//
// array_one
// ---------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// array_two
// ---------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// array_three
// -----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
//
virtual auto length() const noexcept -> size_type
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:122
static auto write(arg_t &&value) -> void
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:490
static auto min(xtd::byte a, xtd::byte b) noexcept -> xtd::byte
Returns the smaller of two 8-bit unsigned integers.

◆ to_string() [4/6]

auto xtd::bit_converter::to_string ( const read_only_span< xtd::byte > & value,
xtd::usize start_index ) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
argument_out_of_range_exceptionstart_index is less than zero or greater than the length of value minus 1.
Remarks
The elements from xtd::array position start_index to the end of the xtd::array are converted. The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// Display a byte array, using multiple lines if necessary.
static void write_multi_line_byte_array(const read_only_span<byte>& bytes, const string& name) {
const auto row_size = 20_z;
const auto underLine = "--------------------------------"_s;
auto iter = 0_z;
console::write_line(underLine.substring(0, math::min(name.length(), underLine.length())));
for(iter = 0; iter < bytes.length() - row_size; iter += row_size) {
console::write(bit_converter::to_string(bytes, iter, row_size));
}
}
// The main entry point for the application.
static auto main() {
auto array_one = array<byte> {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127
};
auto array_two = array<byte> {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129
};
auto array_three = array<byte> {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157
};
console::write_line("This example of the\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize) and\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize, xtd::usize)\n"
"methods generates the following output.\n");
write_multi_line_byte_array(array_one, "array_one");
write_multi_line_byte_array(array_two, "array_two");
write_multi_line_byte_array(array_three, "array_three");
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)
// methods generates the following output.
//
// array_one
// ---------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// array_two
// ---------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// array_three
// -----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
//
Definition __span_definitions.hpp:16

◆ to_string() [5/6]

auto xtd::bit_converter::to_string ( const xtd::array< xtd::byte > & value,
xtd::usize start_index,
xtd::usize length ) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::array of bytes.
start_indexThe starting position within value.
lengthThe number of xtd::array elements in value to convert.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
argument_out_of_range_exceptionstart_index or length is less than zero.
-or-
start_index is greater than zero and is greater than or equal to the length of value.
argument_exceptionThe combination of start_index and length does not specify a position within value; that is, the start_index parameter is greater than the length of value minus the length parameter.
Remarks
AThe length elements from xtd::array position start_index are converted. If length equals zero, the method returns xtd::string.Empty.
The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// Display a byte array, using multiple lines if necessary.
static void write_multi_line_byte_array(const array<byte>& bytes, const string& name) {
const auto row_size = 20_z;
const auto underLine = "--------------------------------"_s;
auto iter = 0_z;
console::write_line(underLine.substring(0, math::min(name.length(), underLine.length())));
for(iter = 0; iter < bytes.length() - row_size; iter += row_size) {
console::write(bit_converter::to_string(bytes, iter, row_size));
}
}
// The main entry point for the application.
static auto main() {
auto array_one = array<byte> {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127
};
auto array_two = array<byte> {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129
};
auto array_three = array<byte> {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157
};
console::write_line("This example of the\n"
" xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and\n"
" xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)\n"
"methods generates the following output.\n");
write_multi_line_byte_array(array_one, "array_one");
write_multi_line_byte_array(array_two, "array_two");
write_multi_line_byte_array(array_three, "array_three");
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)
// methods generates the following output.
//
// array_one
// ---------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// array_two
// ---------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// array_three
// -----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
//

◆ to_string() [6/6]

auto xtd::bit_converter::to_string ( const read_only_span< xtd::byte > & value,
xtd::usize start_index,
xtd::usize length ) -> xtd::string
staticnodiscard

Converts the numeric value of each element of a specified sub xtd::array of bytes to its equivalent hexadecimal xtd::string representation.

Parameters
valueAn xtd::read_only_span of bytes.
start_indexThe starting position within value.
lengthThe number of xtd::array elements in value to convert.
Returns
xtd::string A xtd::string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A-00".
Exceptions
argument_null_exceptionvalue is null.
argument_out_of_range_exceptionstart_index or length is less than zero.
-or-
start_index is greater than zero and is greater than or equal to the length of value.
argument_exceptionThe combination of start_index and length does not specify a position within value; that is, the start_index parameter is greater than the length of value minus the length parameter.
Remarks
AThe length elements from xtd::array position start_index are converted. If length equals zero, the method returns xtd::string.Empty.
The order of hexadecimal strings returned by the to_string method depends on whether the computer architecture is little-endian or big-endian.
Examples
The following code example converts xtd::byte xtd::arrays to xtd::string objects with the to_string method.
#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
// Display a byte array, using multiple lines if necessary.
static void write_multi_line_byte_array(const read_only_span<byte>& bytes, const string& name) {
const auto row_size = 20_z;
const auto underLine = "--------------------------------"_s;
auto iter = 0_z;
console::write_line(underLine.substring(0, math::min(name.length(), underLine.length())));
for(iter = 0; iter < bytes.length() - row_size; iter += row_size) {
console::write(bit_converter::to_string(bytes, iter, row_size));
}
}
// The main entry point for the application.
static auto main() {
auto array_one = array<byte> {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127
};
auto array_two = array<byte> {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129
};
auto array_three = array<byte> {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157
};
console::write_line("This example of the\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize) and\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize, xtd::usize)\n"
"methods generates the following output.\n");
write_multi_line_byte_array(array_one, "array_one");
write_multi_line_byte_array(array_two, "array_two");
write_multi_line_byte_array(array_three, "array_three");
}
};
}
startup_(bit_converter_to_string_example::program::main);
// This code produces the following output :
//
// This example of the
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize) and
// xtd::bit_converter::to_string(const xtd::array<byte>&, xtd::usize, xtd::usize)
// methods generates the following output.
//
// array_one
// ---------
// 00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00-
// 80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37-
// BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00-
// 00-80-7F
//
// array_two
// ---------
// FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0-
// 0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04-
// 23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81
//
// array_three
// -----------
// 00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00-
// 00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01-
// FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42-
// CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00-
// 00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D
//

Member Data Documentation

◆ is_big_endian

bool xtd::bit_converter::is_big_endian
staticconstexpr

Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.

Returns
Returns true if the architecture is big-endian; false if it is little-endian.
Remarks
Different computer architectures store data using different xtd::byte orders. "Big-endian" means the most significant xtd::byte is on the left end of a word. "Little-endian" means the most significant xtd::byte is on the right end of a word.
Examples
The following code example illustrates the use of the is_big_endian field.
#include <xtd/xtd>
auto main() -> int {
println("This example of the bit_converter::is_big_endian field generates\n"
"the following output when run on x86-class computers.\n");
println("is_big_endian: {}", bit_converter::is_big_endian);
}
// This code produces the following output :
//
// This example of the bit_converter::is_big_endian field generates
// the following output when run on x86-class computers.
//
// is_big_endian: false
static constexpr bool is_big_endian
Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.
Definition bit_converter.hpp:76
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:15

◆ is_little_endian

bool xtd::bit_converter::is_little_endian
staticconstexpr

Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.

Returns
Returns true if the architecture is little-endian; false if it is big-endian.
Remarks
Different computer architectures store data using different xtd::byte orders. "Big-endian" means the most significant xtd::byte is on the left end of a word. "Little-endian" means the most significant xtd::byte is on the right end of a word.
Examples
The following code example illustrates the use of the is_little_endian field.
#include <xtd/xtd>
auto main() -> int {
println("This example of the bit_converter::is_little_endian field generates\n"
"the following output when run on x86-class computers.\n");
println("is_little_endian: {}", bit_converter::is_little_endian);
}
// This code produces the following output :
//
// This example of the bit_converter::is_little_endian field generates
// the following output when run on x86-class computers.
//
// is_little_endian: true
static constexpr bool is_little_endian
Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.
Definition bit_converter.hpp:83

◆ endianness

endian xtd::bit_converter::endianness
staticconstexpr

Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.

Returns
Returns One of xtd::bit_converter::endian values.
Remarks
Different computer architectures store data using different xtd::byte orders. "Big-endian" means the most significant xtd::byte is on the left end of a word. "Little-endian" means the most significant xtd::byte is on the right end of a word.
Examples
The following code example illustrates the use of the endianness field.
#include <xtd/xtd>
auto main() -> int {
println("This example of the bit_converter::endianness field generates\n"
"the following output when run on x86-class computers.\n");
println("endianness: {}", bit_converter::endianness);
}
// This code produces the following output :
//
// This example of the bit_converter::endianness field generates
// the following output when run on x86-class computers.
//
// endianness: little
static constexpr endian endianness
Indicates the xtd::byte order ("endianness") in which data is stored in this computer architecture.
Definition bit_converter.hpp:90

The documentation for this class was generated from the following file: