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  
Share this Question
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  
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  
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  
P: n/a

"Zorpiedoman" <no*********@beatles.com> wrote in message
news:B5**********************************@microsof t.com... 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."
Funny. When I learned it in grade 9 it had nothing to do with banking or
engineering, it was just math (yes grade 9 math was more complicated than
grade 3 math, just like calculus is more complicated than grade 3 math). In
university I learned why engineers had better make sure to do rounding this
way, coding it themselves if the hardware didn't do it for them. From your
posting I learn that bankers find it equally important.
But it's still not the fault of bankers or engineers or mathematicians. If
you believe in Intelligent Design then it's God's fault. As for your
trouble with grade 9 math, whose fault is that? I do agree with one of your
observations though. When Microsoft graduated from grade 3 to grade 9, it
was a breaking change.  
P: n/a

Zorpiedoman,
This is one of the changes in VS 2005, it allows more kind of roundings.
Cor  
P: n/a

so, nobody answered the question "is this rounding expected and declared to
produce 0 from .5 ?". do IEEE rules commands this?
"Zorpiedoman" <no*********@beatles.com> wrote in message
news:63**********************************@microsof t.com... 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  
P: n/a

Gjuro, produce 0 from .5 ?". do IEEE rules commands this?
Yes as already probably thousand times answered in these newsgroups,
However in my opinon should any good develloper be able to set the rounding
in the style he wishes by creating the code for that himself, if it is not
provided as a standard.
Cor  
P: n/a

Back in the day we had a real simple solutin for this:
i = INT(x + 0.5)
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Gjuro,
produce 0 from .5 ?". do IEEE rules commands this?
Yes as already probably thousand times answered in these newsgroups,
However in my opinon should any good develloper be able to set the rounding in the style he wishes by creating the code for that himself, if it is not provided as a standard.
Cor   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 1712
 replies: 8
 date asked: Nov 21 '05
