in reply to Re^3: number comparison with a twist in thread number comparison with a twist
Is it possible? I guess it is. After all, I have no control over the API. Then again, the prizes I get are end prizes including VAT so they MUST always be describable in whole cents. This is also the reason the database was set up to store them as integer cents, to avoid any rounding issues (that worked very well, right?).
So, truncating to 2 decimal digits is The Right Thing(TM) in this case.
Re^5: number comparison with a twist
by pryrt (Abbot) on Mar 02, 2020 at 16:10 UTC
|
A quibble: truncating is the wrong thing to do, and is the problem with your original int() solution in the first place. Rounding to the nearest cent is the right thing to do (which can be done through round() as I suggested, or using the sprintf() solutions that others have mentioned).
| [reply] [d/l] [select] |
|