• Nice question.

    The trick of adding 0.000000001 to the multiplicand might work sometimes, but it isn't the best way to handle this.

    Until someone introduces proper modern floating point into SQL (which would eliminate the problem completely) the way to handle this is to use round, which means going via numeric. So in this case, change the calculation for Quota3 to be either

    select @Quota3 = round(@Value*cast(1.05 as numeric(5,2)) ,0);

    or

    select @Quota3 = round(cast((cast(@Value as float) * 1.05) as numeric(38,27)),0);

    and the problem goes away. (and of course there should be similar changes in the calculations of the other two numbers).

    Note that it is necessary, in the second version, to change from using real to using float if you want it to work whatever your integer is. Real (float(24)) is not a sensible type to use for this, since it can't represent all 32 bit integers; so it makes sense to change real to float, which can, as well as using round.

    But proper modern floating point would be much much better. It's about time we were hearing something about it for SQL Standards, as it's now 50 months since IEEE 754-2008 was published.

    Tom