Sometimes the simplest problems are harder than they first seem. A client once specified a requirement to me: we'll give you the VAT-inclusive (20%) price; you need to generate invoices showing the net and VAT amounts. Sounds easy, right? net = round(tot*5/6) vat = round(tot/6)
Certain whole numbers can't ever be the result of adding 20% to another whole number. If VAT were 100% instead of 20%, you couldn't have a VAT-inclusive price be odd, for example.
-
-
Now I see, nice one. I would have fallen into this trap with 80% probability. There is a small chance I would think of assert / postcondition or a property base test.... a small chance.
-
I see you think of making impossible state not representable - but since the prices were as they were - that was in fact the real state - not impossible one.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.