Math.Round不守尾随零 [英] Math.Round not keeping the trailing zero

查看:128
本文介绍了Math.Round不守尾随零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要到小数点后两位所有的值到圆形。所以,应该1.401轮1.40,但 Math.Round(价值2)四舍五入为1.4。

I need all values to rounded to two decimal places. So 1.401 should round to 1.40, but Math.Round(value, 2) rounds to 1.4.

如何能我强迫尾随零?

推荐答案

1.4 相同 1.40 - 你只是想以不同的方式显示。像 value.ToString(0.00)

1.4 is the same as 1.40 - you just want to display it differently. Use a format string when calling ToString - like value.ToString("0.00")

这篇关于Math.Round不守尾随零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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