Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Bankers rule

Why Oracle is not using Bankers rule (the rounding method)?

like image 610
Madhu Avatar asked Aug 18 '09 08:08

Madhu


People also ask

What are matching rules?

A matching rule defines how duplicate records are identified in duplicate rules and duplicate jobs. Salesforce provides standard matching rules for business and person accounts, contacts, and leads. You can also create custom matching rules.

What is the difference between auto and suggested matching?

If the entries matched during auto matching are rejected by the user, the entries become available for re matching. Suggested Match type is allowed only if the amount matching is set as Tolerance. This validation will be done during save operation of the rule definition.


2 Answers

Accurate decimal arithmatic is a large and complex subject.

Google 'mike colishaw decimal rounding' if you want to read the ahem Oracle on the subject.

Basically there are many rounding schemes which are possible:-

Round everthing down - the default in most languages including C as Oracle is written in C this is probably why they do this.

Round everything up - rarely seen but occasionally needs to be implemented because of obscure market and tax rules.

Basic Half Rounding - anything above .5 rounds up everything else rounds down.

Generous Half Rounding - anything below .5 rounds down everthing else rounds up.

Bankers Rounding - Even numbers follow the Basic Half Rounding rule, odd numbers the Generous Half Rounding rule. This is rarely seen in actual banks which prefer rounding up if the moneys coming thier way and rounding down when its going the clients way.

ORACLE NUMBER is actually a pretty good Decimal Arithmatic implementation and is accurate as far as it goes.

like image 160
James Anderson Avatar answered Sep 28 '22 02:09

James Anderson


Oracle has implemented round half away from zero:

SQL> select round(22.5) from dual
  2  /

ROUND(22.5)
-----------
         23

SQL> select round(23.5) from dual
  2  /

ROUND(23.5)
-----------
         24

SQL> select round(-23.5) from dual
  2  /

ROUND(-23.5)
------------
         -24

SQL> select round(-22.5) from dual
  2  /

ROUND(-22.5)
------------
         -23

SQL>

Why don't they change it to Bankers' Rounding? Well, for most purposes round half away from zero is good enough. Plus there's that old fallback, changing it would likely break too much of the existing codebase - Oracle's own as well as all their customers.

like image 31
APC Avatar answered Sep 28 '22 03:09

APC