by Ken Wong (1 Submission)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(8 Votes)
If your application involve ROUNDING NUMBER than you MUST READ this!
Rounding number is important fuction especially if you doing some Accounting, Math, etc calculation. Check the following fact.
Let say, X = 2.344 + 2.341, there for, X = 4.685
Round X to 2 decimal point = 4.68
Refer to IEEE standard,
4.685 rounded to 2 decimal point is 4.68
4.675 rounded to 2 decimal point is 4.68
The problem when you use Round():
Fact 1 : Round(2.344 + 2.341, 2) = 4.69
Fact 2: Round(4.685, 2) = 4.68
You can see the different answer between Fact 1 & 2. In accounting point of view, the 0.01 cent must accountable.
Recommandation:
Use Format() instead of Round()
Example:
Format(2.344 + 2.341, "#.00") = 4.68
Format(4.685, "#.00") = 4.68
Hope this will help.