Home > Net >  C # double calculation problem
C # double calculation problem

Time:11-05

Business code below
Row about 400 rows of data, using double value addition, has nothing to do with the decimal precision, add to the 1.3 million or so he added in the future not
Consult bosses, what's the problem is the data quantity is too much, still need to change a value type, confused
 
double total=0;
While ((nodes=xmlfile SelectSingleNode (" row "+ I))!=null)
{

Int j=1;
System. The Collections. The ArrayList colList=new System. Collections. The ArrayList ();
Foreach (XmlNode xmlnodes in nodes..childnodes)
{
ColList. Add (xmlnodes. The InnerText);
If (j==10)
{
total +=the Convert. ToDouble (xmlnodes. The InnerText. Split (' (') [0]. ToString ());
}
j++;
}
I++

CodePudding user response:

Trouble finishing the code?

CodePudding user response:

See if data overflow, if the data is too large, the data is split into two pieces, said a top, another said after a few;
In addition to see I define numerical range

CodePudding user response:

Good sino-italian CTRL D K

CodePudding user response:

Type double data range is very large, there is no problem for certain, in visible reality environment unless your data is not normal, the double data addition and subtraction can't get correct results:
Double. NaN
Double. NegativeInfinity
Double. PositiveInfinity

CodePudding user response:

 
Double total=0;
While ((nodes=xmlfile SelectSingleNode (" row "+ I))!=null)
{

Int j=1;
System. The Collections. The ArrayList colList=new System. Collections. The ArrayList ();
Foreach (XmlNode xmlnodes in nodes..childnodes)
{
ColList. Add (xmlnodes. The InnerText);
If (j==10)
{
Total +=the Convert. ToDouble (xmlnodes. The InnerText. Split (' (') [0]. ToString ());
}
j++;
}
I++

CodePudding user response:

Don't go up, what does that mean?
Exception?

CodePudding user response:

Under you confirmed is not up?
Or do you Convert. ToDouble out number has a problem?

CodePudding user response:

The original poster in the wrong, we all use a DECIMAL, must solve, you are asking for trouble, personal feeling
  •  Tags:  
  • C#
  • Related