|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 4:22 PM
Points: 10,990,
Visits: 10,542
|
|
No worries Hugo, though I am a little depressed that the values I chose don't make the difference easier to spot - it really wasn't my intention for this question to be a test of reading skills
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Today @ 2:06 PM
Points: 576,
Visits: 27,681
|
|
Good question! The following discussion is making it even better. We should be careful when using exact numeric data types both from the point of view of storing and calculations.
Thanks
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Wednesday, October 24, 2012 8:17 PM
Points: 1,558,
Visits: 247
|
|
Good question Paul, thanks for submitting.
http://brittcluff.blogspot.com/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:25 PM
Points: 7,110,
Visits: 7,184
|
|
SQL Kiwi (1/3/2012)
No worries Hugo, though I am a little depressed that the values I chose don't make the difference easier to spot - it really wasn't my intention for this question to be a test of reading skills  It is a good question. Nicely shoots down the myth that these fixed point "exact" numerics have fewer (or less serious) rounding issues than floating point approximate numerics.
I would have thought that if anyone ran it they would notice the difference between 570 and 567 as the last three digits of the result, so it hardly seems a test of reading skills.
But why run it, when it's clear that using decimal(38,20) to multiply these two numbers will run you head on into the draconian rounding used for "exact" numerics?
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Sunday, November 18, 2012 8:54 PM
Points: 37,
Visits: 29
|
|
| Ohh come on!! I'm wrong again. I'm starting to think this is not meant for common people. LOL! But i'm learning much so thanks. ;)
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 4:22 PM
Points: 10,990,
Visits: 10,542
|
|
L' Eomot Inversé (1/3/2012) It is a good question. Nicely shoots down the myth that these fixed point "exact" numerics have fewer (or less serious) rounding issues than floating point approximate numerics. Thank you!
L' Eomot Inversé (1/3/2012) I would have thought that if anyone ran it they would notice the difference between 570 and 567 as the last three digits of the result, so it hardly seems a test of reading skills. That's perhaps true, but it did catch Hugo, so I do have a small regret about not using an example that left no room at all for misreading.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 4:22 PM
Points: 10,990,
Visits: 10,542
|
|
Diogy (1/3/2012) Ohh come on!! I'm wrong again. I'm starting to think this is not meant for common people. LOL! But i'm learning much so thanks. ;)
You're welcome!
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 8:56 PM
Points: 1,060,
Visits: 4,182
|
|
Luckily I had had my coffee first!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 3:03 PM
Points: 5,244,
Visits: 7,061
|
|
L' Eomot Inversé (1/3/2012) I would have thought that if anyone ran it they would notice the difference between 570 and 567 as the last three digits of the result, so it hardly seems a test of reading skills. On my system, the results displayed ended in 57 (not 570) and 567 - both in grid and text mode. But that's not what tricked me. I ran the code after replying. I had it wrong for the simple reason that I forgot to check the precision and scale of the result for the decimal, even though I am VERY much aware of this issue (and have, in fact, explained this on several online forums, inclding this one, a multitude of times already!).
If I had bothered to REALLY look at the resutls (instead of casually glancing them) after running the code, I would immediately have understood where my error was. But I didn't, I was already so convinced that Paul mistook the displayed result of the real value for the actual result that I neither checked the results with appropriate attention to detail, nor read the explanation accurately enough. Sometimes, I have an idea stuck in my head so tightly that I fail to open my mind to other possibilities. Today was such a day.
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:25 PM
Points: 7,110,
Visits: 7,184
|
|
Hugo Kornelis (1/3/2012) Sometimes, I have an idea stuck in my head so tightly that I fail to open my mind to other possibilities. Today was such a day. It happens to all of us - and to me more often than I like to admit.
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|