How can you get the number of digits contained in a double?

Sim*_*ian 3 c# digits

I'm trying to get the number of digits in the following double value: 56.46855976 without using converting it to a string (and simply replacing the "." with a "").

Anybody got any ideas?

Mar*_*ngs 5

计算你必须将数字除以10的频率,直到它小于1 - >,它会给出小数点前的数字.

然后计算你必须将原始数字乘以10的频率,直到它等于Math.Floor-result - >,它给出了小数点后面的数字.

加.乐于.

编辑:正如乔伊指出的那样,它有一些不确定性.事先定义最大位数,这样就不会创建无限循环.另一方面 - "丹麦海岸有多长?"......