我目前正在从字符串中读取一个长数字。该数字是 3 位整数,后跟 7 位没有小数的十进制数字(例如1234567890
)。
在解析之前如何划分这个数字?
我正在尝试将其解析为整数,但整数的最大值约为 20 亿。
这是我尝试过的:
class Program
{
static void Main(string[] args)
{
using (StreamReader reader = new StreamReader("CLIFF.dat"))
{
string line;
var locations = new Dictionary<string, int[]>() {
{"210", new [] {405, 4, 128, 12, 141, 12, 247, 15}},
{"310", new [] {321, 4, 112, 12, 125, 12, 230, 15}}, //
{"410", new [] {477, 4, 112, 12, 125, 12, 360, 15 }}
};
while ((line = reader.ReadLine()) != null)
{
var lineStart = line.Substring(0, 3);
if (lineStart == "210" || lineStart == "310" || lineStart == "410")
{
var currentLocations = locations[lineStart];
var letters = line.Substring(currentLocations[0], currentLocations[1]);
var transactionvolume =
int.Parse(line.Substring(currentLocations[2], currentLocations[3])) +
int.Parse(line.Substring(currentLocations[4], currentLocations[5]));
var watching = line.Substring(currentLocations[6], currentLocations[7]);
var number = int.Parse(line.Substring(currentLocations[6], currentLocations[7])*));
是当前位置[6]数太大,需要乘以10^-7。