Whats the proper/best way to use pe:inputNumber
for exact big decimals? I have to accept currency input which can have up to 4 decimals, and must not be rounded. Right now I am doing the following:
public void withdraw(Number amount) {
BigDecimal d = new BigDecimal(amount.doubleValue());
// process
}
and
<pe:inputNumber roundMethod="S" decimalPlaces="4" symbol="#{applicationBean.currentCurrencySymbol}" required="true" value="#{flowScope.Amount}"/>
<p:commandButton value="Proceed" type="submit" ajax="true" actionListener="#{myBean.withdraw(flowScope.Amount)}"
</p:commandButton>
My concern is that value gets converted to Double
internally by InputNumber
which can potentially lead to rounding errors when I convert it into BigDecimal
.