当前位置:网站首页>C# 四舍五入 MidpointRounding.AwayFromZero
C# 四舍五入 MidpointRounding.AwayFromZero
2022-08-10 00:41:00 【王源骏】
四舍五入 在计算中 经常使用到,但是如果使用 Math.Round,只是五舍六入
在Math.Round内传入MidpointRounding.AwayFromZero枚举,就可以实现四舍五入的效果了,
Debug.Log($"四舍五入{
66.6}。。。{
(int)Math.Round(66.6, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.5}。。。{
(int)Math.Round(66.5, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.4}。。。{
(int)Math.Round(66.4, MidpointRounding.AwayFromZero)}");
Debug.Log($"四舍五入{
66.6}。。。{
(int)Math.Round(66.6)}");
Debug.Log($"四舍五入{
66.5}。。。{
(int)Math.Round(66.5)}");
Debug.Log($"四舍五入{
66.4}。。。{
(int)Math.Round(66.4)}");
边栏推荐
猜你喜欢

What should I do if there is no sound after reinstalling the system in win10?

数据建模已死,真的吗?

Docker 面试题2则--取数据库连接数和docker-compose

20220809-PotPlayer如何设置默认字体色-设置默认字体色的方法

即时通讯开发如何撸一个WebSocket服务器

【毕业设计】 基于Stm32的家庭智能监控系统 - 单片机 图像识别 人体检测 AI

How to add control panel to right click menu in win7

Win7怎么把控制面板添加到右键菜单

CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG derivative

【无标题】
随机推荐
走出迷宫的最少步数2
Summary of basic operations of c language files
信息化和数字化的核心差异
【Django】缓存
CAS:851113-28-5 (生物素-ahx-ahx-酪胺)
人际关系不仅要“存”,更要“激活”!
有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测
五种定位——粘性定位
Xi'an biotin-tetrapolyethylene glycol-amide-4phenol light yellow semi-solid
R语言使用cox函数构建生存分析回归模型、使用subgroupAnalysis进行亚组分析并可视化森林图
OSS-访问oss生成的url无法访问,直接下载问题
Kubernetes YAML编写 讲解
Qt的pro文件递归搜寻添加文件
GBJ1510-ASEMI机器人电源整流桥GBJ1510
【软考软件评测师】软件测试基础知识
惊掉你下巴,程序员编码竟然可以被 996 指数化
解决sed替换文本,里面含有“/“、“#”等特殊字符的问题
Entity FrameWork Core教程,从基础应用到原理实战
RedHat红帽RHEL7安装与使用,VMware Workstation16 Pro虚拟机的安装与使用
What should I do if there is no sound after reinstalling the system in win10?
