ikr / money-math-php

gmp-based arbitrary precision operations on currency amounts "XXX.YY"; because floats are BAD for representing money

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Moneymath with added precision support

tschallacka opened this issue · comments

Hey, I thought your Decimal2 is fantastic, but for database decimal with precicion to float conversion was less then accurate.
So i took what is yours, modified it to support precicion.

Hope you like it. Please have a look see and possibly upload it too to your github. I did not modify everything, just the calculation of numbers behind the .
Thanks for the great code.

https://gist.github.com/8ec4a38db78701e7bbc6.git

Hi @tschallacka

Thanks! However, I don't think I should merge that. You see, MoneyMath\Decimal2 is solving a different problem. It's not intended to be a universal decimal ADT with arbitrarily limited precision. As the namespace suggests, it only targets the money amounts, rounding to a cent. For general-purpose arbitrary precise decimals you'd need a different solution.

Of course, you're welcome re-purpose the MIT-licensed code in any way you find useful. I'm glad I could give you a foundation.