大家好,刚才写了一个代码,但是最后结果小数被四射五入成一位了,既:1.1 正常的是:1.083 应该怎么能显示正确啊? string[] line1 = line.Split('|');
String line5 = line1[3].ToString();
float.TryParse(line5.ToString(), out f);
f1 = f1 + (f / 100);
this.label1.Text = f1.ToString();
String line5 = line1[3].ToString();
float.TryParse(line5.ToString(), out f);
f1 = f1 + (f / 100);
this.label1.Text = f1.ToString();
double y = x % 0.01;
double z = x - y;
double result = Math.Round(d,2);
Math.Round(f1, 2, MidpointRounding.AwayFromZero);
String line5 = line1[3].ToString();
float.TryParse(line5.ToString(), out f);
f1 = f1 + (f / 100);
this.label1.Text = f1.ToString("0.00");
这样就行啦,有那么麻烦嘛
这样好象成的了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Collections;namespace ConsoleApplication1
{
class Program
{ public Program()
{
double s = 1.555;
Console.WriteLine( Math.Round(s, 2) );
} static void Main(string[] args)
{
Program p1 = new Program();
Console.ReadLine();
}
}
}