如何舍入十进制值 [英] How do I Round up the Decimal Value

查看:48
本文介绍了如何舍入十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何累计总价值



如果数字是16.136

它应该看起来像16.140和

如果数字是16.132

它应该看起来像16.130

How Do I Round up the Total Value Like

if The Number is 16.136
it should look like 16.140 and
if the number is 16.132
it should look like 16.130

推荐答案

使用Math.Round [ ^ ]

Use Math.Round[^]
decimal d = 16.136M;
Console.WriteLine(Math.Round(d, 2));    // 16.14
d = 16.132M;
Console.WriteLine(Math.Round(d, 2));    // 16.13


这篇关于如何舍入十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆