 <p>Calculating the length of a floating-point number decimal representation doesn't make much sense, as its underlying representation is binary. For example 0.1 in decimal form yields an infinite number of digits in binary.</p> <p>C has no intrinsic decimal type, so you will have to represent your number with some ad-hoc type, and shave off insignificant digits on the right. C-strings are not the worse choice for that.</p>