This is not possible in the way you think.
A
double is just a number. It doesn't have a specified number of digits after the decimal point. 0.000 is exactly the same as 0.0 or 0.00000000 or 0. It's just zero.
Prashant Langade wrote:I tried with
but this gives me result as 0.0 and hence the
comes as 1.
That is really strange, because "0.0" is 3 characters, not 1.
If you want to format a number with a specified number of decimals after the decimal point, you have to specify that at the place you're converting the number to a
string. The number of decimals is not some property of the number itself.