This file contains utilities for accessing digits of integers, and for converting them to strings.  
More...
#include <assert.h>
#include <algorithm>
#include <limits>
#include <type_traits>
Go to the source code of this file.
 | 
| char *  | write_two_digits (int value, char *to) | 
|   | Writes an integer, which is between 0 (inclusive) and 100 (exclusive), to a string in base 10.  More...
  | 
|   | 
| template<typename T >  | 
| constexpr int  | count_digits (T x) | 
|   | Counts the number of base 10 digits in an unsigned integer.  More...
  | 
|   | 
| template<typename T >  | 
| char *  | write_digits (T number, int digits, char *to) | 
|   | Writes an unsigned integer of the specified length to a string.  More...
  | 
|   | 
This file contains utilities for accessing digits of integers, and for converting them to strings. 
 
◆ count_digits()
template<typename T > 
  
  
      
        
          | constexpr int count_digits  | 
          ( | 
          T  | 
          x | ) | 
           | 
         
       
   | 
  
constexpr   | 
  
 
Counts the number of base 10 digits in an unsigned integer. 
- Parameters
 - 
  
    | x | the number whose digits to count  | 
  
   
- Returns
 - the number of digits in the number 
 
 
 
◆ write_digits()
template<typename T > 
  
  
      
        
          | char * write_digits  | 
          ( | 
          T  | 
          number,  | 
         
        
           | 
           | 
          int  | 
          digits,  | 
         
        
           | 
           | 
          char *  | 
          to  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Writes an unsigned integer of the specified length to a string. 
The string is not zero-terminated.
- Parameters
 - 
  
     | number | the number to write  | 
     | digits | the number of digits to write (the number is zero-padded if it is shorter)  | 
    | [in,out] | to | the destination string  | 
  
   
- Returns
 - pointer to the character just after the last digit 
 
 
 
◆ write_two_digits()
  
  
      
        
          | char * write_two_digits  | 
          ( | 
          int  | 
          value,  | 
         
        
           | 
           | 
          char *  | 
          to  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Writes an integer, which is between 0 (inclusive) and 100 (exclusive), to a string in base 10. 
Always writes two digits, zero-padded if necessary. The string is not zero-terminated.
- Parameters
 - 
  
     | value | the number to write  | 
    | [in,out] | to | the destination string  | 
  
   
- Returns
 - pointer to the character just after the last digit