Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!sdd.hp.com!decwrl!apple!motcsd!mcdcup!mcdchg!ddsw1!corpane!herman From: herman@corpane.UUCP (Harry Herman) Newsgroups: comp.sys.handhelds Subject: Re: HP48 thinks -3 in binary is zero! Message-ID: <2674@corpane.UUCP> Date: 1 Aug 90 01:35:19 GMT References: <576@cbnewsb.ATT.COM> <4060@memqa.uucp> Organization: Corpane Industries Inc., Louisville, KY Lines: 44 In <4060@memqa.uucp> r91400@memqa.uucp (Michael C. Grant) writes: >In article <576@cbnewsb.ATT.COM>, neal@druhi.ATT.COM (Neal D. McBurnett) writes: |> I was shocked to discover that adding #5h and -3 yields #5h! |> Upon further inquiry, it turns out that << -3 R->B >> produces #0h. |> I would expect it to produce the two's complement value using the |> current wordsize, e.g. #FFFDh. |It was my understanding that binary/hex/octal/decimal numbers (the ones |with '#' preceding them) were unsigned integers. Thus, -3 would indeed |convert to #0h, or result in an error (which I would personally prefer). |Allowing signed numbers of this type would produce inconsistencies if |you changed the width of the number in mid-calculation. For example, |if you had set the width to 8, typed the number |#11110000b |into the calculator, and then changed the width to 16, what would happen? |Well, I personally prefer |#0000000011110000b |instead of the other alternative--sign extension. |Perhaps the easiest way to get around this problem would be to write |your own version of a two's complement routine, and convert ALL of your |numbers that way, so that any negative numbers would be converted properly. |I'd give you the program but I don't have my calculator handy (and I'm |not very good at remembering the keywords). |Michael C. Grant I really like the HP-28 and the HP-48 (especially the HP-48), but I would like HP to consider supporting signed binary math in a future release. It is very annoying to have to get my old HP-16 back out whenever I need to to math on negative binary numbers. Since some people (like Michael, above) like the current behaviour, then maybe have yet another flag that specifies whether to do signed math or unsigned math. I REALLY do need to do signed math on occasion, and would rather have a method built into the calculator to do it automatically (and correctly) than having to role my own. Harry Herman herman@corpane ..uunet!corpane!herman