Where to use Java's BigDecimal?
A example where it can be used is in applications which needs floating points with built in rounding facility.
Consider a case, where money is stored as a decimal in database. Sql mapping link states: "The recommended Java mapping for the
Lets say we want to compute a currency of another country. With currency conversion rate, a currency can be converted into required one. Using BigDecimal's divide method one can achieve it by mentioning the scale factor and rounding strategy.
2 is the scale (decides the number of digits after decimal point) and ROUND_HALF_EVEN strategy is banker's rounding.
A example where it can be used is in applications which needs floating points with built in rounding facility.
Consider a case, where money is stored as a decimal in database. Sql mapping link states: "The recommended Java mapping for the
DECIMAL
and NUMERIC
types is java.math.BigDecimal
. The java.math.BigDecimal
type provides math operations to allow BigDecimal
types to be added, subtracted, multiplied, and divided with other BigDecimal
types, with integer types, and with floating point types."Lets say we want to compute a currency of another country. With currency conversion rate, a currency can be converted into required one. Using BigDecimal's divide method one can achieve it by mentioning the scale factor and rounding strategy.
2 is the scale (decides the number of digits after decimal point) and ROUND_HALF_EVEN strategy is banker's rounding.
BigDecimal amount = new BigDecimal(1); BigDecimal rate = new BigDecimal(3); BigDecimal destinationAmount = amount.divide(rate, 2, BigDecimal.ROUND_HALF_EVEN);
How to fathom Oracle 11g Decimal Issue? Contact to Remote DBA Services
ReplyDeleteProphet decimal issue is a standout amongst the most widely recognized issue which typically looked by the Oracle client. In any case, with some fundamental abilities and information you can without much of a stretch handle this issue however in the event that not then you can choose Database Administration for Oracle or Online Oracle DB Support for fast Oracle decimal issue. Our exceptionally experienced specialized specialists give you cost-sparing administrations which drive better consistency all through the Oracle condition.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801