Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucsd!usc!jarthur!nntp-server.caltech.edu!piglet!madler From: madler@piglet.caltech.edu (Mark Adler) Newsgroups: comp.sys.handhelds Subject: Re: HP48 thinks -3 in binary is zero! Message-ID: <1990Jul2.203602.13767@laguna.ccsf.caltech.edu> Date: 2 Jul 90 20:36:02 GMT References: <576@cbnewsb.ATT.COM> Sender: news@laguna.ccsf.caltech.edu Organization: California Institute of Technology, Pasadena Lines: 18 >> Upon further inquiry, it turns out that << -3 R->B >> produces #0h. I think this is documented. Unlike the HP-16C, the HP-48SX (and it's ancestors, the 28C and 28S) don't believe in negative binary numbers. If you're below the range of non-negative integers allowed by the current wordsize, you get zero from R->B, and if you're above, you get the word filled with binary one's (i.e. FFFFh if the wordsize is 16). It wouldn't be a big deal, nor largely inconsistent if it did convert negative numbers properly, but it doesn't. The fix is simply to convert the positive number and negate it. For example, this program converts positives or negatives to binary like one would want it to: << DUP ABS R->B SWAP IF 0 > THEN NEG END >> Mark Adler madler@tybalt.caltech.edu