Decimal.Round疯狂 [英] Decimal.Round lunacy

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

问题描述

关于Decimal.Round的文档......


"当d恰好在两个舍入值之间时,结果是

在最右边小数位置具有偶数位的舍入值。对于

示例,当舍入到两位小数时,值2.345变为2.34并且

值2.355变为2.36。这个过程被称为向甚至四舍五入,或者将
四舍五入到最近。


我不得不反对。我会选择更像这个过程是已知的

任意忽略事实上的标准。有没有人有一个明智的

方法返回正确的舍入值,即不求助于

decimal.round(x + 0.00000001,2)


并且有没有人有理由对这种荒谬可笑?


-

对于真实回复地址,丢失现金
www.realuk.co.uk

解决方案

这实际上非常标准。在谷歌搜索文件和

这样....


Rob Oldfield < R

OB @ oldfi

eld100.freese

From the documentation about Decimal.Round....

"When d is exactly halfway between two rounded values, the result is the
rounded value that has an even digit in the far right decimal position. For
example, when rounded to two decimals, the value 2.345 becomes 2.34 and the
value 2.355 becomes 2.36. This process is known as rounding toward even, or
rounding to nearest."

I''d have to disagree. I''d go for something more like "This process is known
is arbitrarily ignoring a de facto standard." Does anyone have a sensible
method of returning the correct rounded value i.e. without resorting to
decimal.round(x+0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk

解决方案

This is actually pretty standard. Do a search on google for papers and
such....

"Rob Oldfield" <r


ob@oldfi


eld100.freese


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

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