电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

Kingdee.BOS.MathUtil.Round 十进制四舍五入/双精度数四舍五入

来源:金蝶云社区作者:金蝶2024-09-165

Kingdee.BOS.MathUtil.Round 十进制四舍五入/双精度数四舍五入

#region 程序集 Kingdee.BOS, Version=7.7.2297.10, Culture=neutral, PublicKeyToken=null

// D:\WorkSpace\SZLS\HANS_CLOUD\K3Cloud\BIN\Kingdee.BOS.dll

// Decompiled with ICSharpCode.Decompiler 6.1.0.5902

#endregion


using System;


namespace Kingdee.BOS

{

    //

    // 摘要:

    //     数学运算工具类

    public class MathUtil

    {

        //

        // 摘要:

        //     四舍五入模式,可配置 暂时设置为四舍六入五成双

        private static MidpointRounding mode;


        //

        // 摘要:

        //     十进制四舍五入

        public static decimal Round(decimal value, int decimals = 0, RoundMode mode = RoundMode.AwayFromZero)

        {

            if (mode == RoundMode.AwayFromZero || mode == RoundMode.ToEven)

            {

                MidpointRounding midpointRounding = MidpointRounding.AwayFromZero;

                if (mode == RoundMode.ToEven)

                {

                    midpointRounding = MidpointRounding.ToEven;

                }


                return Math.Round(value, decimals, midpointRounding);

            }


            decimal d = Convert.ToDecimal(Math.Pow(10.0, decimals));

            decimal d2 = value * d;

            d2 = ((mode != RoundMode.Carry) ? Math.Truncate(d2) : Math.Ceiling(d2));

            return d2 / d;

        }


        //

        // 摘要:

       

Kingdee.BOS.MathUtil.Round 十进制四舍五入/双精度数四舍五入

#region 程序集 Kingdee.BOS, Version=7.7.2297.10, Culture=neutral, PublicKeyToken=null// D:\WorkSpace\SZLS\HANS_CLOUD\K3Cloud...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信