Sum on real number field gives funky results with decimals

  • I have a Real Number column I am summing in a T-SQL statement. As long as there are whole numbers in the field, it works fine. When I put a couple single decimal numbers in there (in this case 7.2 and 26.7), instead of the sum end in .9, it's ending in .900000572205. Can somebody explain how that happens?

  • 'Real' like 'float' is an approximate data type. There are some numbers that can't be exactly represented. If you need fixed precision, you should probably use numeric(s,p) instead of real. BOL has a good explanation of the differences.


    And then again, I might be wrong ...
    David Webb

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply