|Instead of dogma, do the tests I noted: how large is the difference in the example given? When would it (ever) show up in a result? Retail sales and financial institutions both deal in money/curacy, but not in the same way.
Well - I happened to have my SQL open and here's a test, done for you:
DECLARE @a float = 0.1
DECLARE @b float = 0.2
DECLARE @c float = 0.3
Now, you tell me how this would effect retail when prices are rounded to 1E-2 ?
Sure - you can work out a unique scenario. Note, too, that when I did it like this:
SELECT (0.3 - (0.2+0.1) ) I got 0.0 as the result
Also, if I declared a DECIMAL (instead of FLOAT) I get zero.
Am I saying that FP doesn't suffer from a loss of precision due to the inability to represent most non-whole-numbers precisely? NO. I'm saying that for practical use, in normal business environment, the loss would never show. Comparisons - done after rounding - would work fine. Indeed, even in the most precise decimal representation, if some item is priced at 3 for $1, how much does one cost? How is that represented? An infinite number of 3's or a round off error? If you buy the 3 items as 3 separate line items, does it now equal $1.00? Yes? The system has rules to handle it. No? Then you have gained nothing in a retail scenario, except the more CPU-intensive processing.
These values eventually need to be stored: what data type do you use in MS SQL Server ?
|Ravings en masse^|
|"The difference between genius and stupidity is that genius has its limits." - Albert Einstein|
|"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010|
modified 11-Jan-21 9:00am.