[JIRA] Closed: (OFBIZ-377) Need usage of fixed point (versus floating point) decimal datatypes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[JIRA] Closed: (OFBIZ-377) Need usage of fixed point (versus floating point) decimal datatypes

JIRA jira@ofbiz.org
     [ http://jira.undersunconsulting.com/browse/OFBIZ-377?page=all ]
     
Jacopo Cappellato closed OFBIZ-377:
-----------------------------------

    Resolution: Fixed

I think that we can close this issue now since we are already using BigDecimals (even if there are still some areas that need to be converted).

> Need usage of fixed point (versus floating point) decimal datatypes
> -------------------------------------------------------------------
>
>          Key: OFBIZ-377
>          URL: http://jira.undersunconsulting.com/browse/OFBIZ-377
>      Project: [OFBiz] Open For Business
>         Type: Bug
>     Versions: SVN, 3.5.0
>  Environment: Any
>     Reporter: Bradley Plies
>     Assignee: Jira Administrator
>  Attachments: entity-engine-bigdecimal-support.patch, webtools-bigdecimal-support.patch
>
>
> java.lang.Double and the associated primitive type double is frequently used for monetary calculations.  This is strongly cautioned against.  Please see a IBM's DeveloperWorks Article "Java theory and practice: Where's your point?"  
> http://www-128.ibm.com/developerworks/java/library/j-jtp0114/ 
> There are many hazards that are commonly overlooked and when it comes to financial information, exactness is critical.
> "Don't use floating point numbers for exact values. Some non-integral values, like dollars-and-cents decimals, require exactness. Floating point numbers are not exact, and manipulating them will result in rounding errors. As a result, it is a bad idea to use floating point to try to represent exact quantities like monetary amounts. Using floating point for dollars-and-cents calculations is a recipe for disaster. Floating point numbers are best r0eserved for values such as measurements, whose values are fundamentally inexact to begin with."
> For example, ( 0.1 * 26 ) != ( 0.1 + 0.1 + 0.1 + .... + 0.1 ) [26 times]
> I've seen this problem manifest in OFBIZ already where in an order, line items totaled $60.00 and a credit card payment of 59.99 was applied, leaving a balance of $0.00.  The franctional penny inexactness manifested into the display.
> The solution is to use java.math.BigDecimal for arbitrary precision.  It always stores the exact value which can be formatted to display-only in a certain precision.  Also it provides accessor methods .doubleValue() (just like Double) and .intValue().  So it should be pretty painless to use.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.undersunconsulting.com/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira