December 26, 2014 at 8:59 pm
When I cast Real to Money it makes some changes to the number
DECLARE @i REAL = 989500000.00;
SELECT CAST(@i AS MONEY)
the result is : 989500032.00
what should I do for stop this ?
December 26, 2014 at 9:53 pm
If you can, use FLOAT instead of the REAL datatype. The REAL datatype has limited precision, and the conversion from the internal base 2 to base 10 results in these types of conversion difficulties.
Better yet, store your values in a numeric datatype to avoid the base 2 to base 10 conversion problems. The FLOAT and REAL datatypes should not be used for anything except scientific calculations.
DECLARE @i float(53) = 989500000.00;
SELECT CAST(@i AS MONEY)
December 26, 2014 at 10:46 pm
tnx, problem solved 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply