截断小数到2位小数位 [英] Truncate a decimal to 2 decimal place.s

查看:105
本文介绍了截断小数到2位小数位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要TRUNCATE,而不是ROUND。我希望消息框中的输出为小数点后2位。



以下是代码。



I want to TRUNCATE, NOT ROUND. I want the output in the messagebox to at 2 decimal places.

Here is the code below.

decimal amountPerHour = Convert.ToDecimal(GlobalVariables._salaryAmount / 52 / 48);

            amountPerHour = TruncateDecimal(0.275, 2);
            MessageBox.Show("The amount is " + amountPerHour.ToString());











基本上全局变量是数据库中的数字。并且它被传递,基本上无论该值是什么,我想被分割并计算并放在小数点后2位。



我知道答案是16.25但是它出现在16或16.00我不想要它四舍五入。我希望它被截断为16.25



帮助请






Basically the global variable is a number in a database. and its being passed through and basically whatever that value is, i want to be divded and calculate and put at 2 decimal places.

I know the answer is 16.25 but it comes out at either 16 or 16.00 i dont want it rounded. i want it truncated to 16.25

Help Please

推荐答案

这篇关于截断小数到2位小数位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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