How to get floats value without including exponential notation

后端 未结 5 1067
自闭症患者
自闭症患者 2021-01-02 01:04

In C#, is it possible to perform ToString on a float and get the value without using exponentials?

For example, consider the following:

float dummy;
         


        
5条回答
  •  醉梦人生
    2021-01-02 01:24

    Without some further background info, it's hard to tell - but it sounds like you want decimal semantics. So why not use the decimal type instead?

    decimal dummy;
    dummy = 0.000006M;
    

    The decimal type is more accurate at representing decimal numbers than float or double, but it is not as performant. See here for more info.

提交回复
热议问题