473,804 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Decimal.Round lunacy

From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is known
is arbitrarily ignoring a de facto standard." Does anyone have a sensible
method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk
Jul 21 '05 #1
17 2735
This is actually pretty standard. Do a search on google for papers and
such....

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is known is arbitrarily ignoring a de facto standard." Does anyone have a sensible
method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk

Jul 21 '05 #2
Ooops.. Its called Banker's rounding
"NoOne" <No@Where.com > wrote in message
news:eN******** *****@TK2MSFTNG P09.phx.gbl...
This is actually pretty standard. Do a search on google for papers and
such....

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is

known
is arbitrarily ignoring a de facto standard." Does anyone have a sensible method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk


Jul 21 '05 #3
I repeat. It's lunacy. It might be a good idea, but the fact is that
NOBODY ACTUALLY DOES IT THIS WAY.

Well, that might be an exaggeration, but very few people.

--
For real reply address, lose the cash
www.realuk.co.uk

"NoOne" <No@Where.com > wrote in message
news:#k******** ******@TK2MSFTN GP10.phx.gbl...
Ooops.. Its called Banker's rounding
"NoOne" <No@Where.com > wrote in message
news:eN******** *****@TK2MSFTNG P09.phx.gbl...
This is actually pretty standard. Do a search on google for papers and
such....

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is

known
is arbitrarily ignoring a de facto standard." Does anyone have a

sensible method of returning the correct rounded value i.e. without resorting

to decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk



Jul 21 '05 #4
write your own method then.

make an enum of values ( like odd, even digits )
and make up a rule.

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is known is arbitrarily ignoring a de facto standard." Does anyone have a sensible
method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk

Jul 21 '05 #5
I could do that, yes. The reason for the question is with the hope that
somebody else has already done it and would be willing to share their code.

I still say that it's ludicrous that MS didn't get it right to start off
with. Would it be OK if the '+' operator worked perfectly except on
Tuesday's. Perfectly simple to replace function add(x,y) with....

dim newY
if day=tuesday
newY=y*-1
add=x-y
else
add=x+y
end if

....but still monumentally stupid.

--
For real reply address, lose the cash
www.realuk.co.uk
"c# newbie" <no****@leave.m e.alone> wrote in message
news:31******** *************** *******@news.te ranews.com...
write your own method then.

make an enum of values ( like odd, even digits )
and make up a rule.

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is

known
is arbitrarily ignoring a de facto standard." Does anyone have a sensible method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk


Jul 21 '05 #6
MS has a reason for doing it, but you're not alone in your frustration, b/c
many don't realize it until after it's too late. At least an overload
should have been provided so you can use either method IMHO.
"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
From the documentation about Decimal.Round.. ..

"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."

I'd have to disagree. I'd go for something more like "This process is known is arbitrarily ignoring a de facto standard." Does anyone have a sensible
method of returning the correct rounded value i.e. without resorting to
decimal.round(x +0.00000001,2)

And has anyone got any justification for this ludicrousness?

--
For real reply address, lose the cash
www.realuk.co.uk

Jul 21 '05 #7
William Ryan <do********@com cast.nospam.net > wrote:
MS has a reason for doing it, but you're not alone in your frustration, b/c
many don't realize it until after it's too late. At least an overload
should have been provided so you can use either method IMHO.


Rather than an overload, there should be an enumeration of rounding
types, or possibly something like the Encoding hierarchy.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #8
Rob Oldfield <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote:
I repeat. It's lunacy. It might be a good idea, but the fact is that
NOBODY ACTUALLY DOES IT THIS WAY.

Well, that might be an exaggeration, but very few people.


I suspect that decimal is generally intended for financial
applications, and given that the name is "banker's rounding" my guess
is that it's not uncommon in that sector. I don't personally have a lot
of experience with the financial sector - do you?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #9
The app that I'm writing that this error has just come up is for an
investment house. When I told their accounts manager that this was the
problem his reaction was "That's absolutely ludicrous. I've never heard of
anyone doing it that way."

This is in the UK though, it may be that things are different in the US, but
certainly 'rounding' over here is 100% 'round halves upwards'.

--
For real reply address, lose the cash
www.realuk.co.uk

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Rob Oldfield <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote:
I repeat. It's lunacy. It might be a good idea, but the fact is that
NOBODY ACTUALLY DOES IT THIS WAY.

Well, that might be an exaggeration, but very few people.


I suspect that decimal is generally intended for financial
applications, and given that the name is "banker's rounding" my guess
is that it's not uncommon in that sector. I don't personally have a lot
of experience with the financial sector - do you?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
951
by: Rob Oldfield | last post by:
From the documentation about Decimal.Round.... "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." I'd have to disagree. I'd go for something more like "This process...
0
9710
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.