! @brief count digits Count the number of decimal (base 10) digits for an input unsigned integer. @param[in] x unsigned integer number to count its digits @return number of decimal digits */
| 16070 | @return number of decimal digits |
| 16071 | */ |
| 16072 | inline unsigned int count_digits(number_unsigned_t x) noexcept |
| 16073 | { |
| 16074 | unsigned int n_digits = 1; |
| 16075 | for (;;) |
| 16076 | { |
| 16077 | if (x < 10) |
| 16078 | { |
| 16079 | return n_digits; |
| 16080 | } |
| 16081 | if (x < 100) |
| 16082 | { |
| 16083 | return n_digits + 1; |
| 16084 | } |
| 16085 | if (x < 1000) |
| 16086 | { |
| 16087 | return n_digits + 2; |
| 16088 | } |
| 16089 | if (x < 10000) |
| 16090 | { |
| 16091 | return n_digits + 3; |
| 16092 | } |
| 16093 | x = x / 10000u; |
| 16094 | n_digits += 4; |
| 16095 | } |
| 16096 | } |
| 16097 | |
| 16098 | /*! |
| 16099 | @brief dump an integer |
nothing calls this directly
no outgoing calls
no test coverage detected