473,804 Members | 4,272 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
17 2735
....and something else I didn't think of in my previous answer....

The vast majority of bankers thoughout the world are using Excel. The round
function in Excel works on the 'round halves up' method. Either they all
know about the difference between their hand-crafted figures and the central
office system and they've given themselves a way around it, or there are a
lot of pennies going missing somewhere.

Next question: can you think of a way of funnelling all these pennies into
an account that I'll set up tomorrow?

--
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 #11
This isn't going to solve the problem for you, but it does provide
justification: http://tinyurl.com/vv4v

Colin

"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 #12
Thanks for that. I get the justification and it does indeed make sense (in
much the same way that the optimal keyboard layout as opposed to QWERTY),
but the problem is if nobody in the real world actually uses it. As I've
said elsewhere in this thread, it may be that US bankers do, but UK ones
certainly don't.

I'd also say that it's not the way that the function works that is the
problem but, as Jon and William point out, that there isn't a sensibly
accessible method of choosing what method to use.

--
For real reply address, replace the _surprised_ bits with dots
www.realuk.co.uk
"Colin Young" <x@nospam.com > wrote in message
news:ON******** ******@TK2MSFTN GP09.phx.gbl...
This isn't going to solve the problem for you, but it does provide
justification: http://tinyurl.com/vv4v

Colin

"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 #13

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
And has anyone got any justification for this ludicrousness?


It's not any more ludicrous than deciding that x.5 always rounds up when
it is in fact equally close to the value below it. In fact it is statistically
much
better to sometimes round up and sometimes round down in that case.

Both methods have their place.
I like Jon's idea. There should be an enumeration of rounding types.

-- Kevin Gale
Jul 21 '05 #14
I always found it VERY odd that Excel used Arithmetic rounding (.5 rounds
up), where as VBA (which is integrated into Excel), and therefore
VisualBasic 6, use Banker's rounding.

If you think Banker's rounding is "lunacy", then you probably have never
done any work in statistics. Using arithmetic rounding is asymmetric, and
can skew data. Very bad....

This page explains rounding and how Excel rounds in various cases.
http://support.microsoft.com/default...b;EN-US;196652

Read down on the page, and it describes the reasoning. Here's an excerpt:

"When you add rounded values together, always rounding .5 in the same
direction results in a bias that grows with the more numbers you add
together. One way to minimize the bias is with banker's rounding.

Banker's rounding rounds .5 up sometimes and down sometimes. The convention
is to round to the nearest even number, so that both 1.5 and 2.5 round to 2,
and 3.5 and 4.5 both round to 4. Banker's rounding is symmetric."

In fact, in any statistics project I did in college, we were required to use
either Banker's rounding or Random rounding. I was annoyed to find that I
had to implement my own rounding function in Excel to do Banker's rounding.
Go figure.

--Matthew W. Jackson

Jul 21 '05 #15
For what it's worth, I never meant to imply that I thought the method of
banker's rounding was lunatic. What I _did_ mean was that Microsoft's
decision to arbitratily impose one method, and to choose a non-standard one,
was lunatic.

--
For real reply address, replace the _surprised_ bits with dots
www.realuk.co.uk

"Matthew W. Jackson" <th************ ********@NOSPAM .NOSPAM> wrote in message
news:Oo******** ******@TK2MSFTN GP11.phx.gbl...
I always found it VERY odd that Excel used Arithmetic rounding (.5 rounds
up), where as VBA (which is integrated into Excel), and therefore
VisualBasic 6, use Banker's rounding.

If you think Banker's rounding is "lunacy", then you probably have never
done any work in statistics. Using arithmetic rounding is asymmetric, and
can skew data. Very bad....

This page explains rounding and how Excel rounds in various cases.
http://support.microsoft.com/default...b;EN-US;196652

Read down on the page, and it describes the reasoning. Here's an excerpt:

"When you add rounded values together, always rounding .5 in the same
direction results in a bias that grows with the more numbers you add
together. One way to minimize the bias is with banker's rounding.

Banker's rounding rounds .5 up sometimes and down sometimes. The convention is to round to the nearest even number, so that both 1.5 and 2.5 round to 2, and 3.5 and 4.5 both round to 4. Banker's rounding is symmetric."

In fact, in any statistics project I did in college, we were required to use either Banker's rounding or Random rounding. I was annoyed to find that I
had to implement my own rounding function in Excel to do Banker's rounding. Go figure.

--Matthew W. Jackson

Jul 21 '05 #16
Always rounding up may be ludicrous, but the point is that it's a standard
ludicrous.

--
For real reply address, replace the _surprised_ bits with dots
www.realuk.co.uk
"Kevin Gale" <kg***@PLEASE-DELETEprintcafe .com> wrote in message
news:10******** *****@mail1.seg net.com...

"Rob Oldfield" <r$ob@oldfi$eld 100.freese$rve. c$o.uk> wrote in message
And has anyone got any justification for this ludicrousness?
It's not any more ludicrous than deciding that x.5 always rounds up when
it is in fact equally close to the value below it. In fact it is

statistically much
better to sometimes round up and sometimes round down in that case.

Both methods have their place.
I like Jon's idea. There should be an enumeration of rounding types.

-- Kevin Gale

Jul 21 '05 #17

"Rob Oldfield" <rob@oldfield10 0_wow_freeserve _yikes_co_incre dible!_uk> wrote in
message news:uV******** ******@TK2MSFTN GP11.phx.gbl...
Always rounding up may be ludicrous, but the point is that it's a standard
ludicrous.


Standard for who? Microsoft does it both ways in different products and Borland
uses banker's rounding in most of it's products but has a few exceptions. I'm
positive that a little research would come up the lots of products that do it
one way and lots the other. Seems like the problem is that there is no standard
(although I'm told that the IEEE 754 floating-point standard does specify
banker's rounding).

I agree with you in the sense that it should be a standard one way or the other.
Having it change from one product to another is just asking for trouble.

-- Kevin
Jul 21 '05 #18

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,...
1
10329
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
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...
1
7626
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
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?
3
3000
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.