A
Anonymous
Guest
Hi guys,
I've stumbled across a (probably common) problem when calculating a summary of prices. Here's the example:
2 items @ 4.25
- 10% discount per item (price-(price*0.1)) = 3.825 (php is rounding this to 3.83)
When I calculate the a subtotal it returns 7.65 (which is correct) but this does not tally with the items listed at 3.83 x 2.
The prices are being extracted from MySQL in a DECIMAL(10,2) datatype. I have tried to alter this to DECIMAL(10,4), but no difference.
I think I need to somehow calcuate the prices with 4 decimal places? But I'm not sure how to do it.
Has anyone overcome this sort of thing before?
Many thanks in advance.
I've stumbled across a (probably common) problem when calculating a summary of prices. Here's the example:
2 items @ 4.25
- 10% discount per item (price-(price*0.1)) = 3.825 (php is rounding this to 3.83)
When I calculate the a subtotal it returns 7.65 (which is correct) but this does not tally with the items listed at 3.83 x 2.
The prices are being extracted from MySQL in a DECIMAL(10,2) datatype. I have tried to alter this to DECIMAL(10,4), but no difference.
I think I need to somehow calcuate the prices with 4 decimal places? But I'm not sure how to do it.
Has anyone overcome this sort of thing before?
Many thanks in advance.