Forum Stats

  • 3,825,012 Users
  • 2,260,455 Discussions


When is the value Zero negative or positive?

OTG-467455 Member Posts: 506 Bronze Badge
edited Nov 23, 2017 4:52PM in Java Puzzle Ball

Examining the savings account and checking account code one sees that only values greater than zero are treated as positive values.

This made me think about the value ZERO.  In mathematics and physics, when is ZERO a negative value, when is it a positive value, is it a sign itself or is it unsigned?

Message was edited by: OTG-467455

Message was edited by: OTG-467455



  • renatorfl
    renatorfl Member Posts: 1
    edited Nov 13, 2017 8:52PM

    Hi OTG-467455,

    I never tried to insert a "-0 " value and don't know how java will respond...

    I was thinking to create some kind of an error handler to work with 0 in case of the user inserts it as a value of save or redemptiom.

    Interesting question. Tomorrow I'll try to run some tests.


  • NickR2600-Oracle
    NickR2600-Oracle Member Posts: 530 Employee
    edited Nov 15, 2017 2:12PM

    I tried a little experiment in Java 9's JShell.  0 might be a special case where it's never represented with a negative sign.  Even manually entering -0 as a value seems to have the same effect as creating any other mathematical expression (like 2+2) which is first evaluated before the resulting value is stored.  -0 seems to be the same as saying -1*0.


    I think you make a good point about the lab.  Maybe some banks would find it desirable to make a deposit of 0, just to initialize or troubleshoot an account.

  • OTG-467455
    OTG-467455 Member Posts: 506 Bronze Badge
    edited Nov 17, 2017 3:12AM

    Zero is neither a negative nor a positive number or value.  It is the starting point for non-negative (Positive) values and non-positive (Negative) values.  As such, zero does not have a sign.

    Non-Negative numbers, are all positive numbers and include zero.  Non-Positive numbers are all negative numbers including zero. These are also sets, set of non-negative values and the set of non-positive values.

    Zero is the midpoint between all negative and all positive values.