Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    1,074

    Unanswered: rounding methodology

    Mgmt is requesting Oracle's rounding methodology. I found something in the documentation that mentions that Oracle supports "rounding up" for NUMBER datatypes, which from what I can tell translates to:

    Last digit is <= 4, round down
    Last digit is >=5, round up

    Code:
    SQL> create table nmbr (f1 number(1));
    
    Table created.
    
    SQL> insert into nmbr select (1.49) from dual;
    
    1 row created.
    
    SQL> select * from nmbr;
    
            F1
    ----------
             1
    
    SQL> truncate table nmbr;
    
    Table truncated.
    
    SQL>  insert into nmbr select (1.5) from dual;
    
    1 row created.
    
    SQL> select * from nmbr;
    
            F1
    ----------
             2
    Makes sense to me, but is "rounding up" some ANSI standard terminology for the above finding? I guess I'd like to show them some official documentation, as to avoid any confusion.

    -Chuck

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Anacedent's link will show you how to round dates, and here you'll be able to read about rounding numbers.

    Never mind all those links ...
    I don't know background of their request, but - Chuck, what's wrong with your management? Do we have the same people there? Guess not, although it seems so Did they go to elementary school? Did they learn how to round numbers? And why do they expect Oracle to round numbers differently? Or did they - as a part of team building - read Christopher Priest's Inverted World and now have doubts in even obvious things?

    I bet their next request will be to proove that Oracle doesn't believe the Moon is in the water but in the sky :sarcastic

  4. #4
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    I believe there are a number of different methods for rounding. AIUI 'Standard Rounding' is traditional rounding which we are probably all familiar with. There is also 'Bankers Rounding' (IIRC round towards even). There may also be others.

    I guess their question relates to these?

    IEEE have specifications for rounding of floating point numbers too :-)

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  5. #5
    Join Date
    Dec 2003
    Posts
    1,074
    Since we're going to be dealing with monetary amounts, they just want to be confident in tracking values. In Sybase, there was an actual currency datatype which tracked all values to 4 places beyond the decimal point. In Oracle, they're deciding if that's going to be the better method, or if a NUMBER(x,2) will work fine.

    I guess they were also curious if Oracle simply truncated numbers beyond the PRECISION value, or if things were rounded.

    -cf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •