/// <summary> /// 返回数值指定的单位的中文大写 /// </summary> /// <param name="numberic"></param> /// <param name="CN"></param> /// <returns></returns> public static string GetNumCN(decimal numberic, NumericUnit CN) { decimal w = numberic - (numberic % 10000); decimal q = (numberic - w) - (numberic - w) % 1000; decimal b = (numberic - w - q) - (numberic - w - q) % 100; decimal s = (numberic - w - q - b) - (numberic - w - q - b) % 10; decimal y = (numberic - w - q - b - s) - (numberic - w - q - b - s) % 1; decimal j = (numberic - w - q - b - s - y) - (numberic - w - q - b - s - y) % 0.1M; decimal f = (numberic - w - q - b - s - y - j) - (numberic - w - q - b - s - y - j) % 0.01M; switch (CN) { case NumericUnit.万: return(GetNumericCnName(Convert.ToInt32(w / 10000))); case NumericUnit.仟: return(GetNumericCnName(Convert.ToInt32(q / 1000))); case NumericUnit.佰: return(GetNumericCnName(Convert.ToInt32(b / 100))); case NumericUnit.拾: return(GetNumericCnName(Convert.ToInt32(s / 10))); case NumericUnit.元: return(GetNumericCnName(Convert.ToInt32(y / 1))); case NumericUnit.角: return(GetNumericCnName(Convert.ToInt32(j * 10))); case NumericUnit.分: return(GetNumericCnName(Convert.ToInt32(f * 100))); } return(""); }
public void NumericConversions(double value1, NumericUnit units1, double value2, NumericUnit units2) { new Numeric(value1, units1) { Units = units2 }.Value.ShouldBeWithinEpsilonOf(value2); new Numeric(value2, units2) { Units = units1 }.Value.ShouldBeWithinEpsilonOf(value1); }