Skip to content
  • Projects
  • Groups
  • Snippets
  • Help

Codecrew / Moya

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 30
  • Merge Requests 2
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
Merged
Merge Request !260 opened Mar 29, 2015 by Tuomas Riihimäki@tuomari

Bill rounding

Make product price scale a constant in Bill. We want to calculate all product prices with 4 decimal precision, just in case. And to make a reference quote for future generations: "This should be enough for everyone". We still want to display the price to users with scale 2, but the scaling should be done at the view level, after all calculations have been made.

This commit does not have any functional changes because all data going through database has scale set already to 4. This just makes the value constant and adds some comments to remind that the scale and rounding mode have real world impact..

By default BigDecimal has a huge scale, which causes BigDecimal to act like a float and these become true:

  • new BigDecimal(555.55) -> 555.549999999999954525264911353588104248046875
  • 55554 == new BigDecimal(555.55).multiply(new BigDecimal(100)).intValue();
Edited Mar 29, 2015
Request to merge tuomari:billrounding into master

Merged

  • The changes were merged into master.
  • The source branch has been removed.
  • Discussion 0
  • Commits 1
  • Changes 5
  • {{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Juho Juopperi @jkj

    Status changed to merged

    Mar 29, 2015

    Status changed to merged

    Toggle commit list
  • Juho Juopperi @jkj

    mentioned in commit 7a882794

    Mar 29, 2015

    mentioned in commit 7a882794

    Toggle commit list
  • Write
  • Preview
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
  • Please register or sign in to post a comment
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View labels
2
2 participants
Reference: codecrew/moya!260