Blaze 3.9
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
43#include <blaze/util/EnableIf.h>
44#include <blaze/util/Types.h>
46
47
48namespace blaze {
49
50//=================================================================================================
51//
52// DIGITS SHIM
53//
54//=================================================================================================
55
56//*************************************************************************************************
74template< typename T
75 , EnableIf_t< IsIntegral_v<T> >* = nullptr >
76constexpr size_t digits( T a ) noexcept
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 the EnableIf class template.
Header file for the IsIntegral type trait.
constexpr size_t digits(T a) noexcept
Returns the number of valid digits of an integral value.
Definition: Digits.h:76
Header file for basic type definitions.