5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
13template<
typename char_t,
typename value_t>
14inline std::basic_string<char_t> __binary_formatter(value_t value,
int precision) {
15 std::basic_string<char_t> result = std::bitset<sizeof(value) * 8>(value).to_string(char_t(
'0'), char_t(
'1'));
16 while (result[0] != 0 && result[0] == char_t(
'0'))
18 if (precision < 0 && result.size() >
size_t(std::abs(precision)))
19 result.append(result.size() - std::abs(precision), char_t(
' '));
21 if (precision == 0) precision = 1;
22 if (
size_t(precision) > result.size())
23 result.insert(0,
size_t(precision) - result.size(), char_t(
'0'));