MCPcopy Create free account
hub / github.com/SheafificationOfG/based-cpp / write_int

Function write_int

gil/std.io.hpp:66–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66template <typename Int> static constexpr auto write_int(auto var) noexcept {
67 using _impl_::tmp;
68 constexpr auto digit = tmp[0];
69 constexpr auto magnitude = tmp[1];
70 constexpr auto ten = static_cast<Int>(10);
71 constexpr auto zero = static_cast<Int>(0);
72
73 return block_(tmp = var, if_(tmp == zero)(putc_('0'), break_),
74 if_(tmp < zero)(putc_('-'), tmp *= static_cast<Int>(-1)),
75 for_(magnitude = static_cast<Int>(1), magnitude <= tmp,
76 magnitude *= ten)(),
77 while_((magnitude /= ten) >
78 zero)(putc_(cast_<char>(tmp / magnitude) + '0'),
79 tmp %= magnitude));
80}
81
82} // namespace integral
83

Callers

nothing calls this directly

Calls 5

block_Function · 0.85
if_Function · 0.85
putc_Function · 0.85
for_Function · 0.85
while_Function · 0.85

Tested by

no test coverage detected