胸径保留一位小数,以2为一个径阶。
double jingji = Convert.IsDBNull(dr["JINGJI"]) ? 0 : Convert.ToDouble(dr["JINGJI"]); jingji = NumberHelper.Round(jingji, 1); newdr["JINGJI"] = jingji; int jj = Convert.ToInt32(Math.Floor(jingji)); if (jj > 0) { if(jj%2==0){ //径阶内 } else{ int minjj = Convert.ToInt32(Math.Floor(jingji)); if (minjj % 2 != 0) minjj -= 1; int maxjj = Convert.ToInt32(Math.Ceiling(jingji)); if (maxjj % 2 != 0) maxjj += 1; double min = jingji - minjj; min = NumberHelper.Round(min, 1); double max = maxjj - jingji; max = NumberHelper.Round(max, 1); if (max > min) { //离哪个近就用哪个 jj = minjj; } else { jj = maxjj; } } newdr["JJ"] = jj; }
……