473,795 Members | 2,867 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 2734
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
9673
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
10448
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
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10167
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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...
1
7544
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
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
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.