[英]how to convert exponential string to normal string in c#
I am reading a column number from csv where the number is 123456791234567 however due to format it gets converted to number="1.23457E+14" in the csv file. 我正在从csv中读取列号 ,其中数字为123456791234567,但是由于格式,它在csv文件中被转换为number =“ 1.23457E + 14” 。
is there any way where we can change it to original string using c# ? 有什么办法可以使用c#将其更改为原始字符串? I am trying with below code : 我正在尝试以下代码:
decimal number = Decimal.Parse(number,System.Globalization.NumberStyles.Any);
but the number i am getting is 123457000000000M and the actual number is 123456791234567 但我得到的电话号码是123457000000000M,而实际电话号码是123456791234567
any idea on this? 有什么想法吗?
If I understand correctly, excel is converting 123456791234567 to 1.23457E+14 . 如果我理解正确,excel 会将 123456791234567转换为1.23457E + 14 。 In that case, you just need to format the excel cell (or potentially the column) containing the value to string, before you set the value. 在这种情况下,您只需要在设置值之前将包含值的Excel单元格(或可能的列)格式化为字符串。
If the C# program opens the csv to find the value to be 1.23457E+14 , then there is no way for you to convert it back to 123456791234567 , since the precision is already lost - unless of course the same value exists (or can be recreated) in other cells (columns) 如果C#程序打开csv来找到值为1.23457E + 14 ,那么您将无法将其转换回123456791234567 ,因为精度已经丢失-除非存在相同的值(或者可以是重新创建)在其他单元格(列)中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.