Last active
October 9, 2017 13:51
-
-
Save VladaHejda/489028b03a3d3bda94738ef2681aee24 to your computer and use it in GitHub Desktop.
MoneyPHP poor rounding :-\
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$item1 = 99; | |
$item2 = 199; | |
$item3 = 57; | |
$credits = 355; | |
$profit = new \Money\Money($total, new \Money\Currency('')); | |
list($discount1, $discount2, $discount3) = $profit->allocate([ | |
($item1 / $total) * 100, // 27.887323943662 | |
($item2 / $total) * 100, // 56.056338028169 | |
($item3 / $total) * 100, // 16.056338028169 | |
]); | |
// $discount1 = 100 ! | |
// $discount2 = 199 | |
// $discount3 = 56 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment