Closed saffabook closed 1 year ago
Hi, allocate()
uses integers as ratios:
public function allocate(int ...$ratios) : array
https://github.com/brick/money/blob/0.7.0/src/Money.php#L513
If you pass integers instead of floats, you get the correct result:
$divided = $currentTotal->allocate(823, 9177); // [8230.00, 91770.00]
I would advise to use strict_types to avoid PHP making a lossy float-to-int conversion in this case.
Thank you.
Am I misunderstanding the allocate function?
I have a total of 100000 I want to allocate this total and split it to the below percentages (which add to 100%); $divided = $currentTotal->allocate(8.23, 91.77);
This gives me the values of [8081, 91919]
But 8.23% of 100000 should be 8230 not 8081
Is there some error that I am doing?