Round() Vs Format()
If your application involve ROUNDING NUMBER than you MUST READ this!
Rate Round() Vs Format()
(8(8 Vote))
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.
Round() Vs Format() Comments
No comments yet — be the first to post one!
Post a Comment