in reply to Applying Sign Bit

Mathmatically, zero is neither positive or negative. What you see is the result of Perl fudging a little.

Also, there is no "flag" value for negative numbers, at least not in the way you're probably thinking. See Twos-complement on Wikipedia. Although the concept is more complex than a simple flag value, it ends up simplifying the logic required for using signed numbers.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Applying Sign Bit
by Anonymous Monk on Jan 22, 2004 at 17:52 UTC
    Also, there is no "flag" value for negative numbers
    Actually, there is. In perl, numbers are normally floating point. Most machines nowadays use IEEE standard floats, which are sign-magnitude, not two's complement. Being able to calculate 1/(-0)=-Inf is supposed to make things easier for certain numerical algorithms.

      While I know a bit about this but I personally would be appreciative if you or someone else well versed in this subject did a meditation on it. Especially from the Perl perspective. (Like Abigails trick of a real small negative number turning into -0.)

      I dont normally upvote anonymonk posts, but I did yours. Thanks.


      ---
      demerphq

        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi