As per what David has explained all doubles are actually stored subtly different to what you think because they round. I just want to extend why they round. They round because the computer works in base 2 (0 and 1's) and you are working in decimal base 10 (0,1,2,..9) 10 does not work as a power of 2 you can go either side 2x2x2=8 OR 2x2x2x2=16 so any base 10 decimal fraction when written in base 2 will likely round Double-precision floating-point format - Wikipedia[^] Assuming you are on a standard Microsoft compiler many will be rounded at 52 bits long and we have no way to know what length you actually typed in. So usually when writing doubles to screen you fix the decimal places Here is how the standard print function does it the %.3f means take float write to 3 decimal places
printf("Double value: %.3f\n", 3.1234543747321475);
I have made a randomly long value but if you execute it only puts out 3 decimal places. There are many conversion routines in C/C++ to convert them in fixed decimal places to screen, buffers etc. So generally you fix the length at display or while the number is in string format, you can't work the problem in reverse the moment it stores the original length is lost. So basically once stored there is no way to count the decimal places .. you can't do what you asked. Lastly should add this is nothing to do with C, any language that stores numbers as doubles behaves that way.
In vino veritas