문제

I have the following string: 2.200000000000E+09

If I do the following:

float.Parse("2.200000000000E+09") = 2.2E+9

If I do:

Int64.Parse("2.200000000000E+09")

I was expecting:

2200000000

Instead I get a format exception so what is the easiest way to get the exponential to integer?

도움이 되었습니까?

해결책

var i = System.Numerics.BigInteger.Parse("2.200000000000E+09",
                         NumberStyles.Float ,
                         CultureInfo.InvariantCulture);

다른 팁

You should use System.Globalization.NumberStyles.Float like:

Int64.Parse("2.200000000000E+09", System.Globalization.NumberStyles.Float);

You can do this using

decimal x = decimal.Parse("2.200000000000E+09", NumberStyles.Float);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top