Loading ...
Sorry, an error occurred while loading the content.
 

Minus zero

Expand Messages
  • jeffonymail
    Something I came across today that I didn t know before: Chipmunk BASIC treats zero differently from minus zero and stores them differently in memory. E.g. the
    Message 1 of 2 , Mar 22, 2011
      Something I came across today that I didn't know before: Chipmunk BASIC treats zero differently from minus zero and stores them differently in memory.

      E.g. the statements:

      x=0 : print x; "and "; str$(x)
      x=-0 : print x; "and "; str$(x)

      Give the output:

      0 and 0
      -0 and -0

      Comfortingly, "if x=0" is true for both 0 and -0

      I don't know if -0 can be generated from arithmetic or whether it can only come from direct assignment (as above) or by reading input.

      ....Jeff
    • jeffonymail
      P.S. Yes, it can be generated internally: x=0 : x=-x : print x prints as -0 ....Jeff
      Message 2 of 2 , Mar 22, 2011
        P.S. Yes, it can be generated internally:

        x=0 : x=-x : print x

        prints as "-0"

        ....Jeff
      Your message has been successfully submitted and would be delivered to recipients shortly.