On 22 Oct 2015 at 21:25, Richard A Rousselot <Richard.A.Rousselot at centurylink.com> wrote:
> I fully expected something like this from a fractional number like 1/3 but > didn't realize that this would be the case if when the digits were explicitly > stated and they summed to a whole number. I will use a Cast statement to > resolve. > On Thu, Oct 22, 2015 at 9:45 PM, Rousselot, Richard A < > Richard.A.Rousselot at centurylink.com> wrote: > >> Doing the following math, why is it that the results are not all >> returning "yes"? >> >> SELECT >> (9.2+7.9+0+4.0+2.6+1.3), >> case when (9.2+7.9+0+4.0+2.6+1.3)=25.0 then "yes" else >> "no" end, >> (9.2+7.8+0+3.0+1.3+1.7), >> case when (9.2+7.8+0+3.0+1.3+1.7)=23.0 then "yes" else >> "no" end, >> (9.2+7.9+0+1.0+1.3+1.6), >> case when (9.2+7.9+0+1.0+1.3+1.6)=21.0 then "yes" else These numbers may be specifiable exactly in decimal to one place of decimals, but can they be expressed exactly in binary floating point? If not, then it's not gonna work. I first came across this issue 50 years ago when I wrote my first program - to calculate square roots using Newton's Method. -- Cheers -- Tim