Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round()..... how and why.

Status
Not open for further replies.

DirectDrive

Programmer
Jan 24, 2003
42
US
I have seen a lot of confusion over the Round function, all over the net and in various books. Some claim it does not work and others seem to have noticed the patter, but do not understand it..
Mathematically speaking the round function is correct, but it does not work how many people think it should. This is how it works…….
When a 5 is encountered it will round to the nearest even number, or it rounds even numbers down and odd numbers up (however you like to think about it). i.e. 2.5 rounds down to 2, 3.5 rounds up to 4.
Mathematicians round like this to combat mathematical bias and the VB round function is based on this theory.
 
Here are a couple of recent threads that can add to or clarify your confusion.

thread222-376567
thread222-376571
thread222-454687 Thanks and Good Luck!

zemp
 
thanks, but i wasn't confused. i just thought i'd try to claify how Round() works since it seems to confuse a lot of people.
 
Yes, it can be confusing. That's why it has been discussed in threads before.

Any clarification is welcome. Thanks and Good Luck!

zemp
 
The real problem is not that the Round function uses a 'round to even' methodolgy (and documents it badly; the VBScript documentation is better in this respect), but that VB isn't consisitent about this with other function that also provide a rounding capability (eg FormatNumber uses a 'round to larger' algorithm)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top