Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Round Function

Posted on 2003-11-06
2
Medium Priority
?
2,256 Views
Last Modified: 2010-05-18
I am trying to round some numbers..while 159.975 is rounding properly, 159.965 isnt.
Shouldn't VB always round up on the 5? It seems to only do it when the digit preceding
it is an odd number.

Round("159.965", 2)     ' RETURNS "159.96"  
Round("159.975", 2)     ' RETURNS "159.98"    

I tried the same thing with FormatCurrency and it works as I expect however I don't
want the dollar sign in front. It's a simple matter to strip the dollar sign with the Replace
function but would like an explanation about why the Round function behaves that way.
Is there a more elegant approach than stripping the '$' sign and using FormatCurrency?

Thanks
0
Comment
Question by:const71
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 90 total points
ID: 9697862
this is a STANDARD rounding procedure for VB.  It is known as "Banker's Rounding", and is discussed at length at

http://support.microsoft.com/default.aspx?scid=kb;EN-US;196652

AW


0
 

Author Comment

by:const71
ID: 9698162
yes but the two methods i showed you provide 2 different ways of rounding. I'll read the article and see what it says...


thanks

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 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