MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / IntToDigits

Method IntToDigits

src/Utilities/GeneralUtils.cpp:168–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168std::string GeneralUtils::IntToDigits(int num)
169{
170 std::string digits;
171 digits.reserve(10); // 32-bit int max: 2,147,483,647 (10 digits)
172
173 if (num == 0)
174 {
175 digits.push_back('0');
176 return digits;
177 }
178
179 while (num)
180 {
181 digits.push_back(static_cast<char>(num % 10) + '0');
182 num /= 10;
183 }
184
185 std::reverse(digits.begin(), digits.end());
186
187 return digits;
188}
189
190int GeneralUtils::CountDigitsInNumber(int number)
191{

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected