decimal and double ToString problem
and Problem double toString Decimal
2023-09-11 14:14:21 时间
decimal d2 = 0.0000002500m;
Console.WriteLine(d2.ToString());
double d3 = 0.0000002500;
Console.WriteLine(d3.ToString());
输出结果是,
0.0000002500
2.5E-07
double在ToString的时候,直接进行了科学计数法。
DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); dataColumn.ColumnName = "column1"; dataColumn.DataType = typeof(decimal); dataTable.Columns.Add(dataColumn); DataColumn dataColumn2 = new DataColumn(); dataColumn2.ColumnName = "column2"; dataColumn2.DataType = typeof(decimal); dataTable.Columns.Add(dataColumn2); decimal d2 = 0.0000002500m; string value2 = d2.ToString(); Console.WriteLine(value2); double d3 = 0.0000002500; string value3 = d3.ToString(); Console.WriteLine(d3.ToString()); var dataRow = dataTable.NewRow(); try { dataRow["column1"] = value2; } catch (Exception ex) { Console.WriteLine(ex.Message); } dataRow["column2"] = value3; Console.WriteLine(dataRow["column1"]); Console.WriteLine(dataRow["column2"]);
需要把这个代码中的decimal修正为double。或者把数据源,修正为decimal
dataColumn2.DataType = typeof(decimal);
相关文章
- hdu1028 Ignatius and the Princess III(递归、DP)
- FastAPI实现谷歌DialogFlow 接口问答批量导入导出和批量删除 DialogFlow batch import and export Q&A interface
- [Nuxt] Use Vuex Actions to Delete Data from APIs in Nuxt and Vue.js
- [Angular 2]ng-class and Encapsulated Component Style2
- [Unit testing RxJS] Testing Observables with Subscribe and assert Parttern
- [AWS] Using EC2 Roles and Instance Profiles in AWS
- [Java Spring Data] @JoinTable, @JoinColumn, joinColumns and inverseJoinColumns
- [TypeScript] Union Types and Type Aliases in TypeScript
- SAP CRM呼叫中心polling and C4C notification polling
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
- 【codeforces 761D】Dasha and Very Difficult Problem
- 【目标检测】20、ATSS: bridging the gap between anchor-based and anchor-free detection via ATSS
- Codeforces Round #253 (Div. 1) B. Andrey and Problem
- 注:检测到当前使用的ADB不是HBuilder内置或自定义ADB:PID为:9544进程名称为:adb.exe 路径为:c:usersadministratorappdatalocaland
- 【CSAPP随笔】CH3:Bits, Bytes, and Integers