gpt4 book ai didi

java - 具有货币格式的 JSF convertNumber 是否舍入或截断额外的小数位?

转载 作者:搜寻专家 更新时间:2023-11-01 01:59:08 26 4
gpt4 key购买 nike

这是一个例子:

    <h:outputText value="#{myBean.myMoney}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>

鉴于我有 1.006 美元,这会输出 1.00 美元还是 1.01 美元?

这里不说: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertNumber.html

最佳答案

Answer=四舍五入

嗯……听起来对吗?我不认为凑钱是个好主意。希望没有银行应用程序会依赖这个。

让人想起《飞越布谷鸟巢》中的这一幕……

[the inmates are playing cards and betting with cigarettes]
Martini: [rips a cigarette in half] I bet a nickel.
McMurphy: Dime's the limit, Martini.
Martini: I bet a dime.
[Puts the two halves onto the table]
McMurphy: This is not a dime, Martini. This is a dime.
[shows a whole cigarette]
McMurphy: If you break it in half, you don't get two nickels, you get shit. Try and smoke it. You understand?
Martini: Yes.
McMurphy: You don't understand.

关于java - 具有货币格式的 JSF convertNumber 是否舍入或截断额外的小数位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/379027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com