Limiting Float datatype to 4 decimal output

  • Let's say I have three fields in a table that are datatype float.

    If I want to write an update script that takes two of the fields into account and update the third, how can I limit the update to only four decimal positions? Is that possible?

    Floatfield3 = Floatfield1 / Floatfield2

    Again, Floatfield3 needs to be limited to just 4 decimal positions.

    Any ideas?

    Thanks.

  • The same way the I did it in FORTRAN over 35 years ago:

    Float3 = Floor(10000 * (Float2 / Float1)) / 10000

    This may be my oldest user-defined function that I have re-used essentially verbatim.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Thanks! I will give it a try!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply