-0

Is -0 a meaningful output ?


SQL> set numf 9
SQL> select -.1 from dual;
-.1
---
 -0

not really :mad:

Put your code in <code> and </code> tags

10 Responses to “-0”

  1. Mihajlo Tekic Says:

    Having in mind that you have set numf to 9, yes it is meaningful :-)

  2. laurentschneider Says:

    is round(-.1) = 0 or -0 ? I think it is a bug

  3. Mihajlo Tekic Says:

    You are right. I think it is a bug too.

  4. Gary Says:

    But NUMF isn’t rounding, it is the display of digits.
    And, to quote Dicken’s Micawber..
    “Annual income twenty pounds, annual expenditure nineteen nineteen six, result happiness. Annual income twenty pounds, annual expenditure twenty pounds ought and six, result misery.”

    So yes, sometimes the -0 may be meaningful.

  5. laurentschneider Says:

    > But NUMF isn’t rounding

    are you sure?

    SQL> set numf 9
    SQL> select 0.4 from dual;
    0.4

    0

    SQL> select 0.6 from dual;
    0.6

    1

  6. Mihajlo Tekic Says:

    The same issue occurs when trying to specify column format

    
    SQL&gt; column num format 9
    SQL&gt; select -.1 num from dual;
    
    NUM
    ---
     -0
    

  7. René Nyffenegger Says:

    > is round(-.1) = 0 or -0 ?

    0 == -0, so round(-.1) = 0 AND round(-.1) = -0

    We happen to be used to represent the number zero as 0, but it seems perfectly legitime to represent it as -0 as well. Not that I like it, though….

  8. laurentschneider Says:

    select to_char(-0.1,’9′),round(-0.1),trunc(-0.1),ceil(-0.1) from duaL
    -0 0 0 0

  9. laurentschneider Says:

    yes rené, but 1+1=+2, I rather say that 1+1=2 :cool:

  10. Rob V Says:

    “yes rené, but 1+1=+2, I rather say that 1+1=2″

    I’m glad you wrote that, that was my spam protection question. :)

Leave a Reply

Use <code> and </code> to post code