Using the Round function in Sybase 12.5

Posted on 2006-03-27
Last Modified: 2010-10-05
If I have the following table:

 ID(integer)   Cost(float)
  2                1.1499999999999999

and then run the following update:

update Table  
            set Cost = round((Cost + 1),2)  
where  ID=2

the result is:

 ID(integer)   Cost(float)
  2                2.1499999999999999

Why isn't Round rounding and what do I achieve the desired affect (where Cost is rounded to 2.15)?


Question by:-Pollo-
    1 Comment
    LVL 2

    Accepted Solution

    Well, it is. The "problem" is this: the base-10 real number 2.15 (and many others) has no exact representation in the floating-point scheme used by Sybase for type float (because it's not base-10, it's base 2 or 16 -- can't remember which). 2.14999999999999 is as good as it gets. Should this worry you? Probably not. Unless you are really concered with precision down to like the 15th position you can safely use floats -- but people will be confused if they are viewing them with many decimal digits.


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now