分类
学习笔记

c#实现excel中的RoundUp和RoundDown

        /// <summary>
        /// RoundUp excel
        /// </summary>
        /// <param name="number"></param>
        /// <param name="digits"></param>
        /// <returns></returns>
        public static double RoundUp(double figure, int precision)
        {
            return Math.Ceiling(figure * Math.Pow(10, precision)) / Math.Pow(10, precision);
        }
        /// <summary>
        /// RoundDown excel
        /// </summary>
        /// <param name="figure"></param>
        /// <param name="precision"></param>
        /// <returns></returns>
        public static double RoundDown(double figure, int precision)
        {
            return Math.Floor(figure * Math.Pow(10, precision)) / Math.Pow(10, precision);
        }

“c#实现excel中的RoundUp和RoundDown”上的1条回复

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据