Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iterator>
- #include <string>
- #include <algorithm>
- #include <string_view>
- #include <charconv>
- std::string to_decimal_string(const int& number, const int& base)
- {
- char out[50]{};
- auto begin = std::begin(out);
- auto end = std::end(out);
- std::string res;
- if (auto [ptr, ec] = std::to_chars(begin, end, number, base); ec == std::errc{}) {
- res.assign(begin, ptr - begin);
- }
- return res;
- }
- int main()
- {
- std::cout << to_decimal_string(100, 2) << std::endl;
- }
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement