d***@googlemail.com
2013-07-29 13:02:46 UTC
Unless anyone can give me a realistic example of why you would need to divide one monetary value by another I have to disagree that this is any kind of issue whatsoever.
We have discovered a interesting rounding "feature" that we would like some
input on.
Check the following set of statements. As it appears T-SQL is very picky
with regards to the syntax required for producing correct results when doing
math on money type fields. As with all these things, doing it right when you
are aware of the problem is usually not a problem..... until some unlucky
guy forgets.
***********
@pab money,
@owf money,
@paf1 money,
@paf2 money
@pab = 4023306.45,
@owf = 89087.50
-- Expected result : 10058.27
Wrong Correct
--------------------- ---------------------
10057.9800 10058.2700
******************
I believe this behaviour is very dangerous. And in this occation it is in
fact about money, large amounts of money. From other langauages I am used to
including a decimal type constant in the expression to force usage of
correct internal storage types during calculation, but in T-SQL it appears
you have to repeat this trick for each element of the expression.
Do we just have to live with this or have we missed out on something here??
TIA,
Erlend
input on.
Check the following set of statements. As it appears T-SQL is very picky
with regards to the syntax required for producing correct results when doing
math on money type fields. As with all these things, doing it right when you
are aware of the problem is usually not a problem..... until some unlucky
guy forgets.
***********
@pab money,
@owf money,
@paf1 money,
@paf2 money
@pab = 4023306.45,
@owf = 89087.50
-- Expected result : 10058.27
Wrong Correct
--------------------- ---------------------
10057.9800 10058.2700
******************
I believe this behaviour is very dangerous. And in this occation it is in
fact about money, large amounts of money. From other langauages I am used to
including a decimal type constant in the expression to force usage of
correct internal storage types during calculation, but in T-SQL it appears
you have to repeat this trick for each element of the expression.
Do we just have to live with this or have we missed out on something here??
TIA,
Erlend