Digits.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SHIMS_DIGITS_H_
36 #define _BLAZE_MATH_SHIMS_DIGITS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/util/Types.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // DIGITS SHIM
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
73 template< typename T >
74 inline constexpr size_t digits( T a ) noexcept
75 {
77 
78  size_t count( 0 );
79 
80  while( a != 0 ) {
81  a /= 10;
82  ++count;
83  }
84 
85  return count;
86 }
87 //*************************************************************************************************
88 
89 } // namespace blaze
90 
91 #endif
Header file for basic type definitions.
constexpr size_t digits(T a) noexcept
Returns the number of valid digits of an integral value.
Definition: Digits.h:74
#define BLAZE_CONSTRAINT_MUST_BE_INTEGRAL_TYPE(T)
Constraint on the data type.In case the given data type T is not an integral data type...
Definition: Integral.h:60
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Constraint on the data type.