On 12 Oct 12:42, Mark Rogers wrote:
Brett Parker wrote:
Can I make a simple suggestion...
Rather than doing the maths in the order that you have in $x do: $x = 10.7 * 15 * 0.01;
I.e. you're doing the division at the end, rather than the beginning, and so the float is "more accurate".
Ah, good point. That's probably why I don't see this all that often; I normally do things that way around for precisely that reason.
Given that the price (10.7) will always be to a maximum of 2 decimal places, how confident can I be that I won't find other cases that fail even though this one now works?
Well, how about giving a range that we can play in, and then I can tell you ;)
Of course, I'm assuming that you're actually pulling these from a database engine, so you could just get that to do the maths... you shouldn't *ever* hardcode VAT rate (as Jenny found out with her invoicing system ;)
Cheers,