MCPcopy Create free account
hub / github.com/Tracktion/choc / getNumDecimalDigits

Function getNumDecimalDigits

choc/math/choc_MathHelpers.h:79–85  ·  view source on GitHub ↗

Returns the number of decimal digits required to print a given unsigned number

Source from the content-addressed store, hash-verified

77
78/// Returns the number of decimal digits required to print a given unsigned number
79inline int getNumDecimalDigits (uint32_t n)
80{
81 return n < 1000 ? (n < 10 ? 1 : (n < 100 ? 2 : 3))
82 : n < 1000000 ? (n < 10000 ? 4 : (n < 100000 ? 5 : 6))
83 : n < 100000000 ? (n < 10000000 ? 7 : 8)
84 : n < 1000000000 ? 9 : 10;
85}
86
87
88//==============================================================================

Callers 1

generateDigitsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected