How can I detect if a float has a repeating decimal expansion in C#?

前端 未结 6 1941
一个人的身影
一个人的身影 2021-01-12 00:16

I simply need to know how I can detect repeating decimal expansion in floats.

Example:

0.123456789123456789

The repeating portion of the number would

6条回答
  •  臣服心动
    2021-01-12 00:21

    you can't detect period like in your example as for representation in base 10, precision of float is 7 digits.

    http://msdn.microsoft.com/en-us/library/aa691146%28v=vs.71%29.aspx

提交回复
热议问题