431,780 Members | 1,549 Online
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

 P: n/a Howcome: Dim D as decimal = .5D msgbox d.Round(D, 0) this returns "0" Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! Documentation says this, but what the heck are they thinking??? I just don't get it. This is insane!?!?!?!! (or maybe I am) "When d is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36. This process is known as rounding toward even, or rounding to nearest." -- --Zorpie Nov 21 '05 #1
8 Replies

 P: n/a It's actually the BANKERS fault: "The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding." Anyway, the reason this all came up was because we were doing some compairson between some old ACCESS reports and some new reports we are designing in VB.NET. In ACCESS, when a value of .05 was FORMATTED "0,0" it returned 0.1, which goes along with my third grade math thinking. When we changed the formula to use the ROUND function, it returned 0. An odd and obscure little gotcha that we just stumbled across, I guess. Oh well, that was fun...! -- --Zorpie "Kerry Moorman" wrote: Zorpie, I suspect that Simple Math, Grade 3 does not comform to IEEE Standard 754 with respect to rounding because IEEE Standard 754 is too complex for third graders. If you want to always use the type of rounding you learned in third grade, then Math.Ceiling might be for you. Kerry Moorman "Zorpiedoman" wrote: Ok, then why does IEEE Standard 754 not comply to Simple Math, grade 3? I really must be going mad. All my life I have been taught that .5 rounds to 1. Microsoft ACCESS will round .5 and get 1. Sheesh. -- --Zorpie "Kerry Moorman" wrote: Zorpie, Rounding in .Net at least claims to follow IEEE Standard 754. Therefore, several different ways to round are provided: Round Ceiling Floor In addition, VB provides several keywords that apply to rounding in one way or another: INT FIX CINT You just need to pick a method or keyword that works the way you need it to for a particular application. Kerry Moorman "Zorpiedoman" wrote: > Howcome: > > Dim D as decimal = .5D > msgbox d.Round(D, 0) > > this returns "0" > > Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! > > Documentation says this, but what the heck are they thinking??? I just don't > get it. This is insane!?!?!?!! (or maybe I am) > > "When d is exactly halfway between two rounded values, the result is the > rounded value that has an even digit in the far right decimal position. For > example, when rounded to two decimals, the value 2.345 becomes 2.34 and the > value 2.355 becomes 2.36. This process is known as rounding toward even, or > rounding to nearest." > > -- > --Zorpie Nov 21 '05 #2

 P: n/a Zorpie, Rounding in .Net at least claims to follow IEEE Standard 754. Therefore, several different ways to round are provided: Round Ceiling Floor In addition, VB provides several keywords that apply to rounding in one way or another: INT FIX CINT You just need to pick a method or keyword that works the way you need it to for a particular application. Kerry Moorman "Zorpiedoman" wrote: Howcome: Dim D as decimal = .5D msgbox d.Round(D, 0) this returns "0" Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! Documentation says this, but what the heck are they thinking??? I just don't get it. This is insane!?!?!?!! (or maybe I am) "When d is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36. This process is known as rounding toward even, or rounding to nearest." -- --Zorpie Nov 21 '05 #3

 P: n/a Zorpie, I suspect that Simple Math, Grade 3 does not comform to IEEE Standard 754 with respect to rounding because IEEE Standard 754 is too complex for third graders. If you want to always use the type of rounding you learned in third grade, then Math.Ceiling might be for you. Kerry Moorman "Zorpiedoman" wrote: Ok, then why does IEEE Standard 754 not comply to Simple Math, grade 3? I really must be going mad. All my life I have been taught that .5 rounds to 1. Microsoft ACCESS will round .5 and get 1. Sheesh. -- --Zorpie "Kerry Moorman" wrote: Zorpie, Rounding in .Net at least claims to follow IEEE Standard 754. Therefore, several different ways to round are provided: Round Ceiling Floor In addition, VB provides several keywords that apply to rounding in one way or another: INT FIX CINT You just need to pick a method or keyword that works the way you need it to for a particular application. Kerry Moorman "Zorpiedoman" wrote: Howcome: Dim D as decimal = .5D msgbox d.Round(D, 0) this returns "0" Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! Documentation says this, but what the heck are they thinking??? I just don't get it. This is insane!?!?!?!! (or maybe I am) "When d is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36. This process is known as rounding toward even, or rounding to nearest." -- --Zorpie Nov 21 '05 #4