为什么在C#中使用UInt64获得这些结果?

时间:2019-06-07 03:25:50

标签: c# uint64

这里有两个UInt64数组:

UInt64[] debit = { 1227472838000, 239613677000, 1280855526000, 235973794000, 916401761000, 778857860000, 613860937000, 323570932000, 1379077243000, 748734870000, 319293438000, 266363662000, 962885150000, 1386950860000, 24497296322000, 1497287074000, 371579620000};

UInt64[] credit = { 1227452838000, 239613641000, 1235410585000, 235973795000, 916342194000, 778887860000, 613859937000, 323660931000, 1379080221000, 748734871000, 319293436000, 200648963000, 962885151000, 1430250860000, 16577296322000,1446583769000, 371579628000};

当我运行这段代码时:

for (int i = 0; i < debit.Length; i++)
{
     Console.WriteLine($"{i+1}) Debit: {debit[i]} Credit: {credit[i]}");
     Console.WriteLine($"Debit - Credit = {debit[i] - credit[i]}");
     Console.WriteLine($"Credit - Debit = {credit[i] - debit[i]}");
     Console.WriteLine("==============================================");
}

我得到这些:

1) Debit: 1227472838000 Credit: 1227452838000
   Debit - Credit = 20000000
   Credit - Debit = 18446744073689551616
==============================================
2) Debit: 239613677000 Credit: 239613641000
   Debit - Credit = 36000
   Credit - Debit = 18446744073709515616
==============================================
3) Debit: 1280855526000 Credit: 1235410585000
   Debit - Credit = 45444941000
   Credit - Debit = 18446744028264610616
==============================================
4) Debit: 235973794000 Credit: 235973795000
   Debit - Credit = 18446744073709550616
   Credit - Debit = 1000
==============================================
5) Debit: 916401761000 Credit: 916342194000
   Debit - Credit = 59567000
   Credit - Debit = 18446744073649984616
==============================================
6) Debit: 778857860000 Credit: 778887860000
   Debit - Credit = 18446744073679551616
   Credit - Debit = 30000000
==============================================
7) Debit: 613860937000 Credit: 613859937000
   Debit - Credit = 1000000
   Credit - Debit = 18446744073708551616
==============================================
8) Debit: 323570932000 Credit: 323660931000
   Debit - Credit = 18446744073619552616
   Credit - Debit = 89999000
==============================================
9) Debit: 1379077243000 Credit: 1379080221000
   Debit - Credit = 18446744073706573616
   Credit - Debit = 2978000
==============================================
10) Debit: 748734870000 Credit: 748734871000
   Debit - Credit = 18446744073709550616
   Credit - Debit = 1000
==============================================
11) Debit: 319293438000 Credit: 319293436000
   Debit - Credit = 2000
   Credit - Debit = 18446744073709549616
==============================================
12) Debit: 266363662000 Credit: 200648963000
   Debit - Credit = 65714699000
   Credit - Debit = 18446744007994852616
==============================================
13) Debit: 962885150000 Credit: 962885151000
   Debit - Credit = 18446744073709550616
   Credit - Debit = 1000
==============================================
14) Debit: 1386950860000 Credit: 1430250860000
   Debit - Credit = 18446744030409551616
   Credit - Debit = 43300000000
==============================================
15) Debit: 24497296322000 Credit: 16577296322000
   Debit - Credit = 7920000000000
   Credit - Debit = 18446736153709551616
==============================================
16) Debit: 1497287074000 Credit: 1446583769000
   Debit - Credit = 50703305000
   Credit - Debit = 18446744023006246616
==============================================
17) Debit: 371579620000 Credit: 371579628000
   Debit - Credit = 18446744073709543616
   Credit - Debit = 8000
==============================================

如何解决这些算术错误?

1 个答案:

答案 0 :(得分:0)

将声明部分更改为

.smallW {
  width: 10%;
  height: 100px;
  background-color: green;
}

.largeW {
  width: 50%;
  height: 100px;
  background-color: blue;
}

.outerWrap {
  display: flex;
}

.innerWrap {
  background-color: yellow;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;/* For center align */
  /* justify-content: flex-end;  */ /* Align to end */
}