Does the JSFNumber with currency format convert rounding or truncation of additional decimal places?

Here is an example:

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

Given that I have $ 1.006, will this yield $ 1.00 or $ 1.01?

It doesnโ€™t say here: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertNumber.html

+4
source share
2 answers

Answer = Rounded

Hmm ... does that sound right? I do not think it is a good idea to combine money. Hopefully no banking apps will rely on this.

This scene comes to mind from "Flying Over the Cuckoo's Nest" ...

[prisoners played cards and bet with cigarettes]
Martini: [rips a cigarette in half] I bet nickel. McMurphy: Give the limit, Martini.
Martini: I bet. [Puts two halves on the table]
McMurphy: This is not a penny, Martini. This is a penny.
[shows the whole cigarette]
McMurphy: If you break it in half, you wonโ€™t get two nickels, you get shit. Try and smoke. You understand?
Martini: Yes. McMurphy: You don't understand.

+6
source

A currency can only be set in 2 decimal places, if set to more than 2 decimal places. If an input with more than two decimal places, the output will be truncated to 2 decimal places.

Logically, $ 1.001 makes no sense, since $ 1 and 1 cent will be $ 1.01, not $ 1.001.

+1
source

All Articles