• Nice to see someone using LOGs. But I would trust your results more if you displayed them, instead of using the WHERE expected_result <> actual_result.

    The problem I found was that you don't get exact representation when using float. Frankly, I have never used float before, so maybe I am doing something incorrectly, but note the example below.

    declare   @num float

               , @res float

               , @digits int

    SET @num = 1.23456678

    SET @digits = 4

    select @res = case when @num > 0

                          then round(@num,@digits-1-floor(log10(@num)))

                          else round(@num,@digits-1-floor(log10(-@num)))

                        end

    select @num as ORIGINAL_NUMBER, @res AS RESULT 

           , @digits as NBR_SIG_DIGITS

    RESULT IS:

    ORIGINAL_NUMBER         RESULT                  NBR_SIG_DIGITS

    1.23456678             1.2349999999999999            4

    Probably not what you really want (I assume you want 1.235 ??)