16,555
社区成员
发帖
与我相关
我的任务
分享
string S;
string 取整;
public string getsingle(double t)
{
if (t > 1)
{
if (t.ToString().Length > 4)
{
S = (t.ToString()).Substring(0, 4);
if (S.IndexOf(".") > 0)
{
S = (t.ToString()).Substring(0, 5);
}
}
else
{
S = t.ToString();
}
}
else if (t < 1)
{
string w = t.ToString();
string[] split = null;
split = w.Split('.');
int 小数部分 = ((int)(Math.Pow(10, split[1].Length) * t));
//string 取整 = (小数部分.ToString()).Substring(0, 4);
if (小数部分.ToString().Length <= 4)
{
取整 = 小数部分.ToString();
S = (Convert.ToInt16(取整) / Math.Pow(10, split[1].Length)).ToString();
}
else
{
取整 = (小数部分.ToString()).Substring(0, 4);
S = (Convert.ToInt16(取整) / Math.Pow(10, 4)).ToString();
}
}
return S;
}
string w = t.ToString();
string[] split = null;
split = w.Split('.');
int 小数部分= ((int)(Math.Pow(10, split[1].Length) * t));
if (小数部分.ToString().Length <= 4)
{
取整 = 小数部分.ToString();
}
else
{
取整 = (小数部分.ToString()).Substring(0, 4);
}
S = (Convert.ToInt16(取整)/ Math.Pow(10, split[1].Length)).ToString();
string S;
public string getsingle(double t)
{
if (t > 1)
{
S = (t.ToString()).Substring(0, 4);
if (S.IndexOf(".") > 0)
{
S = (t.ToString()).Substring(0, 5);
}
}
else if (t<1)
{
string w = t.ToString();
string[] split = null;
split = w.Split('.');
int 小数部分= ((int)(Math.Pow(10, split[1].Length) * t));
string 取整=(小数部分.ToString()).Substring(0,4);
S = (Convert.ToInt16(取整)/ Math.Pow(10, split[1].Length)).ToString();
}
return S;
}
string w = t.ToString();
string[] split = null;
split = w.Split('.');
int 小数部分= ((int)(Math.Pow(10, split[1].Length) * t));
string 取整=(小数部分.ToString()).Substring(0,4);
S = (Convert.ToInt16(取整)/ Math.Pow(10, split[1].Length)).ToString();