Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with tax rounding #199

Merged
merged 1 commit into from Apr 2, 2015
Merged

Fixes issue with tax rounding #199

merged 1 commit into from Apr 2, 2015

Conversation

chrissrogers
Copy link
Member

Summary
  • Instead of using a rounding method prone to floating point math issues, this uses a coercion using exp notation
  • Tests provided in Tax Bug #198

@chrissrogers chrissrogers force-pushed the fix-tax-ceil branch 2 times, most recently from 7fce142 to cff37da Compare March 30, 2015 23:11
- Instead of using a rounding method prone to floating point math issues, this uses a coercion using exp notation

Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
@@ -237,3 +237,16 @@ Calculations.prototype.planPrice = function () {
function decimal (prop) {
this[prop] = (Math.round(Math.max(this[prop], 0) * 100) / 100).toFixed(2);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking I should fix this as well. It's less prone to side effects of floating point math problems because it's using a round and not a ceiling, but it is flawed nonetheless

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method being used is ~36x faster, but the scientific coercion method is absolutely still within bounds of acceptable performance.

http://jsperf.com/decimal-rounding-0

@bhelx
Copy link
Contributor

bhelx commented Apr 2, 2015

👍

bhelx added a commit that referenced this pull request Apr 2, 2015
Fixes issue with tax rounding
@bhelx bhelx merged commit e04662b into master Apr 2, 2015
@bhelx bhelx deleted the fix-tax-ceil branch April 2, 2015 00:10
@bhelx bhelx mentioned this pull request Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants