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

computers suck at math #50

Open
foxdie opened this issue Jul 28, 2014 · 4 comments
Open

computers suck at math #50

foxdie opened this issue Jul 28, 2014 · 4 comments

Comments

@foxdie
Copy link

foxdie commented Jul 28, 2014

hi,

You may have rounding errors in the constructor of BaseTransferInformation :

$amount = (integer) ($amount * 100); //may cause rounding errors

should be replaced with:

$amount = (integer) (round($amount * 100, 0));

see why computers suck at math :
http://www.techradar.com/news/computing/why-computers-suck-at-maths-644771/1

thanks for your work :)

@ghost
Copy link

ghost commented Jan 27, 2016

Casting to integer will result into cut of the number and not into a rounded numbers.
That because you are right.

Normally by casting to integer:
100,5 would result into 100.
100,4 would result into 100.

@nicolasbadia
Copy link

nicolasbadia commented Sep 9, 2016

I'm have rounding issues too.
If I set the amount to 9.78, the output will display 9.77.
The proposed solution worked for me.

@BenjaminPaap
Copy link

Use https://github.com/php-sepa-xml/php-sepa-xml instead. As far as I know we fixed all rounding issues there. It's a fork of this repository which is actively maintained.

@nicolasbadia
Copy link

nicolasbadia commented Sep 9, 2016

Thanks. I will use this fork now.
Also find out that this is fixed in master by 6c68d02 and that this issue is a duplicate of #28

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

No branches or pull requests

3 participants