[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Using the Round function in Sybase 12.5

Posted on 2006-03-27
Medium Priority
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

Accepted Solution

TadHawkins earned 150 total points
ID: 16303865
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Will the future of mobile app development include the same trends as those most relevant today? Find out by checking out the 7 trends of the future.
Applications for our next round of the Experts Exchange Scholarship Contest are starting to roll in. It made us wonder what our past winners are up to these days. Here's a look at what four winners experienced with the contest and what they're doing…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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