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

Problem with cents values from 995 to 999 #31

Closed
sdespont opened this issue Jun 7, 2017 · 3 comments · Fixed by #44
Closed

Problem with cents values from 995 to 999 #31

sdespont opened this issue Jun 7, 2017 · 3 comments · Fixed by #44
Assignees
Labels
Milestone

Comments

@sdespont
Copy link

sdespont commented Jun 7, 2017

In case of the amount is 114.9984, the result is 114 francs and 100 cents instead of 115 francs 0 cent.

1037ca0

@ravage84 ravage84 added the bug label Jun 9, 2017
@ravage84 ravage84 added this to the 0.12.2 milestone Jun 9, 2017
@ravage84
Copy link
Owner

ravage84 commented Jun 9, 2017

Thanks for reporting. Wouldn't it be easier to round first, then split?

@ravage84 ravage84 self-assigned this Jun 9, 2017
@sdespont
Copy link
Author

Yes it would, but the as the amount is not always a float, the type must be checked before :

   // Fix case where cents are from 995 to 999 : the amount must be rounded
   // otherwise the amount of cents is "100"
   if(is_numeric($amount)) {
       $this->amount = round($amount, 2);
   } else {
       $this->amount = $amount;
   }

@ravage84 ravage84 modified the milestones: 0.12.3, 0.12.2 Aug 7, 2017
@ravage84 ravage84 modified the milestones: 0.12.3, 0.13.0, 0.13.1 Feb 27, 2019
@ravage84
Copy link
Owner

Problem can also arise from summing up floats:

https://3v4l.org/4Bhe2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants