Question : Division with fractions ?

I am dividing 0 by  33 and I'm getting 1. I was expecting 0.03.

Declare @P int
Declare @U smallint
set @P = 1
set @U = 33
Print @P / @U
0

Answer : Division with fractions ?

If you divide two ints you get and int back.

Declare @P float
Declare @U float
set @P = 1
set @U = 33
Print @P / @U

or to force the int's to a float

Declare @P int
Declare @U smallint
set @P = 1
set @U = 33
Print 1.0 * @P / @U

Ie, add a float to the formula
Random Solutions  
 
programming4us programming4us