jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Mod4j: Modeling for Java using Domain Specific Languages
  • MODFORJ-9

The decimal type generated as float is not precise

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.0
  • Component/s: None
  • Labels:
    None

Description

The float data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead.

Now fi when the decimal value 9999.9999 is persisted, the retrieved value will be 10000.0.
This is not precise enough for systems that work with currencies.
===================

Eric Jan Malotaux [17/feb/09 11:29 AM] This is probably not a good reason to implement decimal with BigDecimal. Money should be modelled as a value type, with an integer for the value property, and an indicator for the precision. For example, whether the value mean whole currency values, e.g. euro's or dollars, or cents, or another position for the virtual decimal position. And a currency indicator, of course.

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Johan Vogelzang added a comment - 19/Aug/11 8:04 AM

Fixed: changed float into BigDecimal. You can model the decimal property with an literal for precision and scale.

Show
Johan Vogelzang added a comment - 19/Aug/11 8:04 AM Fixed: changed float into BigDecimal. You can model the decimal property with an literal for precision and scale.

People

  • Assignee:
    Johan Vogelzang
    Reporter:
    Jos Warmer
Vote (0)
Watch (0)

Dates

  • Created:
    19/Feb/09 8:06 AM
    Updated:
    19/Aug/11 8:04 AM
    Resolved:
    19/Aug/11 8:04 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.