This is actually pretty standard. Do a search on google for papers and such.... [quoted text, click to view] "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > >
Ooops.. Its called Banker's rounding [quoted text, click to view] "NoOne" <No@Where.com> wrote in message news:eNVORytrDHA.732@TK2MSFTNGP09.phx.gbl... > This is actually pretty standard. Do a search on google for papers and > such.... > > "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message > news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > > > > > >
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. [quoted text, click to view] "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > >
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
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 [quoted text, click to view] "NoOne" <No@Where.com> wrote in message news:#k2BcztrDHA.2060@TK2MSFTNGP10.phx.gbl... > Ooops.. Its called Banker's rounding > > > "NoOne" <No@Where.com> wrote in message > news:eNVORytrDHA.732@TK2MSFTNGP09.phx.gbl... > > This is actually pretty standard. Do a search on google for papers and > > such.... > > > > "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message > > news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > > > > > > > > > > > >
write your own method then. make an enum of values ( like odd, even digits ) and make up a rule. [quoted text, click to view] "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > >
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 [quoted text, click to view] "c# newbie" <nospam@leave.me.alone> wrote in message news:31fe8b295c64c2b472db6cb3b0c6f4f0@news.teranews.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$eld100.freese$rve.c$o.uk> wrote in message > news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > > > > > >
[quoted text, click to view] William Ryan <dotnetguru@comcast.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 - <skeet@pobox.com> http://www.pobox.com/~skeet
[quoted text, click to view] Rob Oldfield <r$ob@oldfi$eld100.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 - <skeet@pobox.com> http://www.pobox.com/~skeet
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 [quoted text, click to view] "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message news:MPG.1a25fb32a695667e989aea@msnews.microsoft.com... > Rob Oldfield <r$ob@oldfi$eld100.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 - <skeet@pobox.com> > http://www.pobox.com/~skeet > If replying to the group, please do not mail me too
....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 [quoted text, click to view] "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message news:MPG.1a25fb32a695667e989aea@msnews.microsoft.com... > Rob Oldfield <r$ob@oldfi$eld100.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 - <skeet@pobox.com> > http://www.pobox.com/~skeet > If replying to the group, please do not mail me too
This isn't going to solve the problem for you, but it does provide justification: http://tinyurl.com/vv4v Colin [quoted text, click to view] "Rob Oldfield" <r$ob@oldfi$eld100.freese$rve.c$o.uk> wrote in message news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > >
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 [quoted text, click to view] "Colin Young" <x@nospam.com> wrote in message news:ONAJ2W5rDHA.2380@TK2MSFTNGP09.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$eld100.freese$rve.c$o.uk> wrote in message > news:ODC7sgtrDHA.1692@TK2MSFTNGP12.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 > > > > > >
[quoted text, click to view] "Rob Oldfield" <r$ob@oldfi$eld100.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
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.aspx?scid=kb;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
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 [quoted text, click to view] "Matthew W. Jackson" <themuujAThotmailDOTcom@NOSPAM.NOSPAM> wrote in message news:OomUkcMsDHA.3492@TK2MSFTNGP11.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.aspx?scid=kb;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 > > >
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 [quoted text, click to view] "Kevin Gale" <kgale@PLEASE-DELETEprintcafe.com> wrote in message news:1069426433.8537@mail1.segnet.com... > > "Rob Oldfield" <r$ob@oldfi$eld100.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 > >
"Rob Oldfield" <rob@oldfield100_wow_freeserve_yikes_co_incredible!_uk> wrote in message news:uVWbrwgsDHA.3492@TK2MSFTNGP11.phx.gbl... [quoted text, click to view] > 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
Don't see what you're looking for? Try a search.
|