关于舍入小数的问题 [英] Question about rounding the decimal

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

问题描述

亲爱的,

在我的vb.net程序中,我必须将十进制数舍入到两位小数

的位置。

For例如,对于表达式Decimal.Round(31 * 1.555,2),我应该

得到结果48.21。但是,该程序最终给出48.20。我的表情有错吗

?请帮忙。

非常感谢,

Ray

Dear all,
In my vb.net program, I have to round a decimal number to two decimal
place.
For example, for the expression "Decimal.Round(31* 1.555, 2)", I should
get the result "48.21". However, the program finally give "48.20". Is there
any mistake for my expression? Please help.
Thanks a lot,
Ray

推荐答案



" ray" < so ***** @ microsoft.comkirjoitti

viestiss?:ud ************** @ TK2MSFTNGP02.phx.gbl ...

"ray" <so*****@microsoft.comkirjoitti
viestiss?:ud**************@TK2MSFTNGP02.phx.gbl...

亲爱的,

在我的vb.net程序中,我必须将十进制数舍入到两位小数

的地方。

例如,对于表达式Decimal.Round(31 * 1.555,2),我应该

得到结果48.21。但是,该程序最终给出48.20。

我的表情有什么错误吗?请帮忙。

非常感谢,


Dear all,
In my vb.net program, I have to round a decimal number to two decimal
place.
For example, for the expression "Decimal.Round(31* 1.555, 2)", I should
get the result "48.21". However, the program finally give "48.20". Is
there any mistake for my expression? Please help.
Thanks a lot,
Ray



非常有趣。

我不能说为什么它会这样,但你可以尝试

格式(31 * 1.555,0.00)。


-Teemu

Quite interesting.

I can''t say why it works like that but you could try
Format(31*1.555,"0.00").

-Teemu


Math.Round((31 * 1.555),2,MidpointRounding.AwayFromZero)


谢谢,


Seth Rowe

ray写道:
Math.Round((31*1.555),2, MidpointRounding.AwayFromZero)

Thanks,

Seth Rowe
ray wrote:

亲爱的所有人,

在我的vb.net程序中,我必须将十进制数舍入到两位小数

的位置。

例如,对于表达式十进制 .Round(31 * 1.555,2)",我应该

得到结果48.21。但是,该程序最终给出48.20。我的表情有错吗

?请帮忙。

非常感谢,

Ray
Dear all,
In my vb.net program, I have to round a decimal number to two decimal
place.
For example, for the expression "Decimal.Round(31* 1.555, 2)", I should
get the result "48.21". However, the program finally give "48.20". Is there
any mistake for my expression? Please help.
Thanks a lot,
Ray


亲爱的,

我试过Math.Round((31 * 1.555),2,MidpointRounding.AwayFromZero)和

问题解决了。

然而,当我试过Math.Round(81.445,

2,MidpointRounding.AwayFromZero),我想该程序应该给我

81.45但实际上它给了我81.44。我的表情有什么不对吗?

请帮忙。

非常感谢,

Ray


" rowe_newsgroups" < ro ******** @ yahoo.com>

???????:11 ***************** *****@f16g2000cwb.googl egroups.com ...
Dear all,
I have tried Math.Round((31*1.555),2, MidpointRounding.AwayFromZero) and
the problem is solved.
However, when I tried Math.Round(81.445,
2,MidpointRounding.AwayFromZero), I suppose that the program should give me
81.45 but actually it give me 81.44. Is there any mistake for my expression?
Please help.
Thanks a lot,
Ray

"rowe_newsgroups" <ro********@yahoo.com>
???????:11**********************@f16g2000cwb.googl egroups.com...

Math.Round((31 * 1.555),2,MidpointRounding.AwayFromZero)


谢谢,


Seth Rowe


ray写道:
Math.Round((31*1.555),2, MidpointRounding.AwayFromZero)

Thanks,

Seth Rowe
ray wrote:

>亲爱的,
在我的vb.net程序中,我必须将十进制数字舍入到两位小数位置。
例如,对于表达式 Decimal.Round(31 * 1.555,2)",
应该得到结果48.21。但是,该程序最终给出48.20。

我的表情有什么错误吗?请帮忙。
非常感谢,
Ray
>Dear all,
In my vb.net program, I have to round a decimal number to two decimal
place.
For example, for the expression "Decimal.Round(31* 1.555, 2)", I
should
get the result "48.21". However, the program finally give "48.20". Is
there
any mistake for my expression? Please help.
Thanks a lot,
Ray



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

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