• Here's another little script to demonstrate the effect of using float. Although the local variable looks pretty good out of a simple "print @i", converting the value to decimal bears out the internal inaccuracy.

    declare @i float

    set @i = .1

    while @i <= 10.0

    begin

    print @i

    print convert(decimal(38,36),@i)

    set @i = @i + .1

    End

    The first few rows returned are here:

    0.1

    0.100000000000000000000000000000000000

    0.2

    0.200000000000000000000000000000000000

    0.3

    0.300000000000000060000000000000000000

    0.4

    0.400000000000000000000000000000000000

    0.5

    0.500000000000000000000000000000000000

    0.6

    0.600000000000000000000000000000000000

    0.7

    0.700000000000000000000000000000000000

    0.8

    0.799999999999999880000000000000000000

    0.9

    0.899999999999999880000000000000000000

    1

    0.999999999999999880000000000000000000

    and the last few are here:

    9.6

    9.599999999999981900000000000000000000

    9.7

    9.699999999999981500000000000000000000

    9.8

    9.799999999999981200000000000000000000

    9.9

    9.899999999999980800000000000000000000

    10

    9.999999999999980400000000000000000000

    It's now obvious that 9.9999999999999804 is not equal to 10.