Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NEG numbers.

59 views
Skip to first unread message

Lennert R. Sluyk

unread,
Oct 31, 1994, 7:16:06 PM10/31/94
to
Howcome I can't take the negative of a number like #73d or #1000011b?
Please help.
I know my calc is just an 48S, but still.

This was some serious information.
*** Lennert 'Iceman' Sluyk. ***
And you can send any messages to l.r.s...@student.utwente.nl

Alfred A. Arduengo

unread,
Oct 31, 1994, 2:07:52 PM10/31/94
to

Correct me if I'm wrong but you can't take the negative of a binary
number or the representation of one in any base. (i.e. HEX, OCT, BIN) Now
I don't have much knowledge of these types of numbers so if I'm wrong
someone tell me NICELY. :)

AL

Eric Crampton

unread,
Oct 31, 1994, 4:28:55 PM10/31/94
to
Alfred A. Arduengo (aard...@lonestar.utsa.edu) wrote:


: On Tue, 1 Nov 1994, Lennert R. Sluyk wrote:

: Correct me if I'm wrong but you can't take the negative of a binary

: number or the representation of one in any base. (i.e. HEX, OCT, BIN) Now
: I don't have much knowledge of these types of numbers so if I'm wrong
: someone tell me NICELY. :)

Actually, binary numbers can take on negative values as well as fractional
values. For example, 13.75 (base 10) equals 1101.11 (base 2). The HP will do
negative binary numbers, at least my GX does and I'd imagine the S-series
would, too. However, they don't do fractional binary numbers; I haven't see
a calculator yet that does, not that it's that terribly important anyway.

--
ecra...@csugrad.cs.vt.edu | "Women... Can't live with 'em, can't shoot 'em.
Eric Crampton | - Steven Wright

YUAN Feng

unread,
Oct 31, 1994, 11:55:51 PM10/31/94
to
Lennert R. Sluyk (s930...@mail.student.utwente.nl) wrote:
: Howcome I can't take the negative of a number like #73d or #1000011b?
: Please help.

Binary integer number on HP48 ( User RPL and System RPL, including system
binary integer ) is unsigned, so negative number can't be
correctly represented. But because binary integer operations do not
check for overflowing, sometimes you can use numbers with first bit
being 1 as negative numbers.

For example,
0 #1h -
returns on stack
# FFFFFFFFFFFFFFFFh
you can use this as -1 in some cases, binary integer addition and subtraction
will work correctly, but comparisons may not work correctly.

One except to this unsigned integer interpretation is the screen coordinates
uses in PIXON, PIXOFF, PIX?, LINE, TLINE, BOX, pixel numbers in the range
#80000h to #FFFFFh are interpreted as negative numbers ( pixels above or to
the left of the screen ).

Y.Feng

Lennert R. Sluyk

unread,
Nov 1, 1994, 4:38:51 PM11/1/94
to aard...@lonestar.utsa.edu
On Mon, 31 Oct 1994 13:07:52 -0600,
Alfred A. Arduengo <aard...@lonestar.utsa.edu> wrote:

>
>
>On Tue, 1 Nov 1994, Lennert R. Sluyk wrote:
>
>> Howcome I can't take the negative of a number like #73d or #1000011b?
>> Please help.

>> I know my calc is just an 48S, but still.
>>
>> This was some serious information.
>> *** Lennert 'Iceman' Sluyk. ***
>> And you can send any messages to l.r.s...@student.utwente.nl
>>
>>

>Correct me if I'm wrong but you can't take the negative of a binary
>number or the representation of one in any base. (i.e. HEX, OCT, BIN) Now
>I don't have much knowledge of these types of numbers so if I'm wrong
>someone tell me NICELY. :)
>

> AL
>
Why not? My 32SII can do neg. binary numbers. All I know about neg. binary
numbers is that the MSB has to be 1. According to my 32SII
-(99d) = -(1100011b) = 111111111111111111111111111110011101b = -99d

Wanna see my signature?

Alex Ramos

unread,
Nov 1, 1994, 12:50:04 PM11/1/94
to
Lennert R. Sluyk (s930...@mail.student.utwente.nl), quoted out of context, wrote:
> On Mon, 31 Oct 1994 13:07:52 -0600,
> >> Howcome I can't take the negative of a number like #73d or #1000011b?
> >> Please help.
> >> I know my calc is just an 48S, but still.
> >>
>
> Why not? My 32SII can do neg. binary numbers. All I know about neg. binary
> numbers is that the MSB has to be 1. According to my 32SII
> -(99d) = -(1100011b) = 111111111111111111111111111110011101b = -99d

You can take the two's complement of a hex string (the "#" numbers) by
doing #0 SWAP -.

For many (but not all) practical purposes, the two's complement is
the same as the negative.

--
Alex Ramos (ra...@engr.latech.edu) * http://info.latech.edu/~ramos/
Louisiana Tech University, BSEE/Sr * Disclaimer: I'm probably wrong.

swd...@genb.cca.cr.rockwell.com

unread,
Nov 1, 1994, 12:49:28 PM11/1/94
to


In article <Pine.SGI.3.91.941031...@lonestar.utsa.edu>, "Alfred A. Arduengo " <aard...@lonestar.utsa.edu> writes:
Path: lazrus.cca.rockwell.com!cacd.rockwell.com!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!swrinde!ringer.cs.utsa.edu!lonestar.utsa.edu!aardueng
From: "Alfred A. Arduengo " <aard...@lonestar.utsa.edu>
Newsgroups: comp.sys.hp48
Subject: Re: NEG numbers.
Date: Mon, 31 Oct 1994 13:07:52 -0600
Organization: The University of Texas at San Antonio
Lines: 19
Message-ID: <Pine.SGI.3.91.941031...@lonestar.utsa.edu>
References: <76539.s...@mail.student.utwente.nl>
NNTP-Posting-Host: lonestar.utsa.edu
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <76539.s...@mail.student.utwente.nl>

I had a Computer Science teacher insist that there were no such things as
negative numbers in any base but ten. (He was adamant on this point.) If
you wished to convert a negative base-ten number into binary, you use
sign-magnitude (where the MSB stands in for the minus sign),
ones-complement or twos-complement (preferred). If you wish to convert a
negative base-ten number into octal or hexadecimal, first convert it into
binary as above and then convert to octal by grouping bit triplets or to
hex by quadruplets.

By the way, there's no such thing as base seven, either. :)

On many calculators which can display hex, octal or binary, negative
numbers base-ten numbers are converted using twos-complement. This is
simply because the vast majority of customers who care about binary or hex
care because they need it for programming. Most computers normally expect
twos-complement, so most customers who want binary want twos-complement, so
calculator makers provide it that way.

Lance ==)--------

-=[ Three boxes keep us free: ballot, jury, and cartridge. ]=-

--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
swd...@afds.cca.rockwell.com -or- || Don't believe everything
lance.r...@servcent.org || you read. Whatever you
8E03 8D25 7D69 07F4 8845 6CCA 28E8 67CF || _do_ believe, make sure
BOMBREAKGBORDERESERVENCRYPTARGETRAITORSA || you DON'T believe the
PGPRESIDENTWACKENHUTFEMARSHALLETHALAJFBI || opinions embodied herein
EXPOSECRETFEDERALIASCIASSASINATEDEAGUNSA || are Rockwell's!
--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

Tim Dixon

unread,
Nov 3, 1994, 12:11:47 AM11/3/94
to

Does the HP (any of them, though I've got a G so I'm mainly interested
in it) have built-in two's complement? If so, why can't it handle neg.
binary numbers? If not, how long would it take to write a couple of
assembly routines to handle the conversion? Five minutes? Ten?


: On Mon, 31 Oct 1994 13:07:52 -0600,

--
_______ Taylor University Computer Science (AI)
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| imothy D. Dixon tdi...@css.tayloru.edu

It is only by the greatest of coincidences that my opinions ever match those
of anybody else, let alone Taylor.

Richard M Presley

unread,
Nov 3, 1994, 2:35:42 AM11/3/94
to
In article <393nin$d...@csugrad.cs.vt.edu>, ecra...@csugrad.cs.vt.edu (Eric Crampton) writes:
> Alfred A. Arduengo (aard...@lonestar.utsa.edu) wrote:
>
>
> : On Tue, 1 Nov 1994, Lennert R. Sluyk wrote:
>
> : Correct me if I'm wrong but you can't take the negative of a binary
> : number or the representation of one in any base. (i.e. HEX, OCT, BIN) Now
> : I don't have much knowledge of these types of numbers so if I'm wrong
> : someone tell me NICELY. :)
>
> Actually, binary numbers can take on negative values as well as fractional
> values. For example, 13.75 (base 10) equals 1101.11 (base 2). The HP will do
^^^ ^^^

Just out of curiosity, how does the binary fractional part work? I've never
seen this done before. If someone would take the time for a quick explanation,
I would be most appreciative.


Thanks,
Rick P
rmp...@tntech.edu

swd...@genb.cca.cr.rockwell.com

unread,
Nov 3, 1994, 11:52:15 AM11/3/94
to

>> Actually, binary numbers can take on negative values as well as fractional
>> values. For example, 13.75 (base 10) equals 1101.11 (base 2). The HP will do
> ^^^ ^^^

> Just out of curiosity, how does the binary fractional part work? I've never
> seen this done before. If someone would take the time for a quick explanation,
> I would be most appreciative.

It's just an extension of the concept of place value. With the place
immediately to the left of the radix (decimal) point as zero, number the
places such that each place's number is one more than the one to its right
and one less than the one to the left. The digit in that place multiplied
by the base raised to the place value is that digit's contribution to the
total:

place num:_876543__2_ _1_ _0_ . _-1_ _-2_ _-3_ _-4_
base 16 1 3 9 D 0 0 0
16^2 16^1 16^0 16^-1 16^-2 16^-3 16^-4

base 13 1 B 1 . A 7 4 0 ... repeating
13^2 13^1 13^0 13^-1 13^-2 13^-3 13^-4

base 10 3 1 3 . 8 1 2 5
10^2 10^1 10^0 10^-1 10^-2 10^-3 10^-4

base 8 4 7 1 . 6 4 0 0
8^2 8^1 8^0 8^-1 8^-2 8^-3 8^-4

base pi 30 2 0 1 . 2 2 0 1 rounded
pi^2 pi^1 pi^0 pi^-1 pi^-2 pi^-3 pi^-4

base 2 100111 0 0 1 . 1 1 0 1
2^2 2^1 2^0 2^-1 2^-2 2^-3 2^-4
place num:_876543__2_ _1_ _0_ . _-1_ _-2_ _-3_ _-4_

Yes, it is meaningful to express the value in base 13 and even base pi,
they're just largely useless. (I'd have used base 42, but I'd run out of
symbols before I ran out of possible place values. :)

I hope this was more helpful than confusing.

Lance ==)--------

-=[ Real computers don't need no steenkin' extensions! ]=-
--

mon...@admu.edu.ph

unread,
Nov 4, 1994, 5:55:05 AM11/4/94
to
Hllo, Folks!

We are trying to interface an HP48SX to a microcontrollervia ASCII/Serial Comm.
Apparently, the HP sends some initialization pulses before sending the actual
ASCII data even when in ASCII/wire mode. These initialization pulses confuses
the microcontroller.

Is there a way of setting up the HP so that no initialization pulses are sent?
That is, we'd like the comm to be purely ASCII/Kermit? (The microcontroller
has built-in MS-Kermit).

Next, when in IR mode, we can (apperently) make the HP send the ASCII data minus
any initialization pulses. Hoever, we can't seem to make it receive data
likewise. Is this a limitation of the machine or are we missing something?

Finally, could somebody please email me a copy of IO.doc (for the HP48SX)?
For some reason I don't yet understand, I 'm unable to connect to hpcvbbs.cv.hp
.com to get my own copy.

Thnks heaps!

Lino

mon...@admu.edu.ph

Johan

unread,
Nov 4, 1994, 12:19:41 PM11/4/94
to
|> Howcome I can't take the negative of a number like #73d or #1000011b?

You can take the negative of a binary number - it just doesn't show up like the nice #-1000011b you might like. The negative of a binary number is computed in two's compliment form, which makes binary subtraction very simple. Two's compliment is to simply reverse all bits then add one - doing this twice gets you your original number! eg with a word size of 8, #1000011b -> #10111101 (you need the wordsize for how many leading 0's). To add, then :
base 10 binary
carry: 111110010
73 01001001
-67 +10111101
-- --------
6 1 00000110
^this extra bit is dropped..past word size.
and #110b = #6d. Two's compliment arithmetic is how computers do signed math, as you can see, it works nicely.

As for fractional binary numbers, I don't know of any calculator that will do this, but you can find it easy enough. Just take the fractional part of the decimal number (eg .47 from 2.47), multiply it by 2^(number of places you want, in this example, 8). This will give you .47*256 = 120.32 Then just convert #120d to binary, you get #1111000b. Count over 8 places, and your fractional part in binary is .01111000, your whole number 2.47d = 10.01111b. Note that this is an approximation out to 8 places-mos
t decimal fractions don't convert to an exact binary fraction. And the reversing the process works to find the decimal of a binary fraction. Ok, maybe it doesn't look easy, but it is easy to write a short prog to do it for you.

|> I know my calc is just an 48S, but still.

The more power to you - that's what I have, too. It's not the size of the tool, but how you use it!! Hope this helped, or at least totally flummoxed your understanding of binary numbers..
________________________________________________________________________________
\God only knows |DON'T PANIC!!!!!!!!!!!!!!!!!!!!!!!!!!!!/
\And God makes his plan. /J\ w **** w /
\The information's unavailable /ohn\ \ ****** | /
\to the mortal man! /Peter\ \___********___/ /
\ (Paul Simon, /Kozura!\ *\__/* /
\ Slip Sliding Away)/kozurj@rp\ **U* /
\__________________________/i.edu(hell)\___________________________/

Seth Arnold

unread,
Nov 4, 1994, 8:09:36 PM11/4/94
to
> By the way, there's no such thing as base seven, either. :)

Sure there is. It just isn't in use. :)


--
"I never let my public schooling get in the way of my education." --
Mark Twain

Jake G Schwartz

unread,
Nov 5, 1994, 12:11:05 PM11/5/94
to
(Time for another shameless plug?)
The HP16C Emulator Library for the HP48

This library encompasses all the functionality in the HP48's native MTH BASE
menu plus all the functionality of the HP16C "computer scientist" calculator
(discontinued around 1987) and more, running in the HP48 RPL environment.
An overview of the library:

The entire HP48 keyboard is redefined and labeled using the supplied
four-color mylar keyboard overlay. No function is more than two
keystrokes away.

LCD shows all modes (current base, word size, complement mode, plus
status of carry and range flags) at all times in the status area.

Entry of binary numbers does NOT require the use of the #-sign de-
limiter; it is added automatically.

Both signed (ones and twos complement) and unsigned numbers are
supported with all math functions.

Keys A through F have been moved down to keyboard row 4 so they are
closer to the numeric keypad.

Illegal numbers are disabled when applicable (i.e., in BINARY base,
keys 2 through F are disabled)

Entry of both integers and reals are permitted without delimiters.
Math on reals still available while library is active.

Negative decimal integers are displayed such as "#-5d" using a custom
display routine.

All emulator library status is preserved when exited and reentered.

All emulator functions may be used in user program objects.

The math functions supported are:

Arithmetic: +, -, *, /, RMD (remainder), NEG, ABS
Double-word: DBL*, DBL/, DBLR (double remainder)
Bit Shift/Rotate: SL, SLn, SR, SRn, RL, RLn, RR, RRn, LJ (left justify),
ASR, RLC (rotate left thru carry), RLCn, RRC, RRCn
Masking: MSKL (mask left), MSKR
Bit Set/Clr/Test: SB, CB, B?, #B (no. of bits set)
Logical: AND, OR, XOR, NOT
Conversion: ->IEEE, IEEE-> (IEEE standard 32-bit format),
FLOAT, FIXED, R->B, B->R
Relational Tests: ==, <> (not equal), <, <=, >=, >
Carry, Range: SETC, CLRC, TC (toggle carry), CRRY?,
SETR, CLRR, TR, RNG?, CCR (clear carry & range)
Complement: UNSGN (unsigned mode), ONES (ones complement),
TWOS (twos complement), CMP? (what is current mode)
Word Size: STWS, RCWS
Math: Square Root, Square, Y^X
Display: #0000... (Leading zero's mode),
MLSHOW (Display full number in multi-line format),
SHOW BIN, SHOW OCT, SHOW DEC, SHOW HEX (displays in
specified base briefly)


The software is available on plug-in 32K ROM card or floppy disk for down-
loading to RAM. The library is about 28K in size. It can be used in any
port on the HP48SX and only in ports zero (built-in RAM) or one (indepen-
dent RAM or as a plug-in ROM card) in the HP48GX. The package includes
library on card or disk, 130-page user manual and mylar keyboard overlay.
The floppy-disk based version is $40.00 and the card-based version is
$75.00. Both include shipping in the U.S. via Priority Mail. (Sorry - I
can't handle credit cards.)

Feel free to contact me by phone or by mail if additional information is
needed.

Jake Schwartz SI...@ESDSDF.DNET.GE.COM
135 Saxby Terrace or
Cherry Hill, NJ Jak...@cup.portal.com
08003-4606
USA

609-751-1310 home (evenings and weekends)
609-722-6695 work (8-5 M-F)

Phantom #138

unread,
Nov 15, 1994, 7:44:45 PM11/15/94
to
Seth Arnold (hid...@agora.rdrop.com) wrote:
: > By the way, there's no such thing as base seven, either. :)

: Sure there is. It just isn't in use. :)

Thats right. There's such thing as all bases if you would like to use
them. To represent a negative number in binary you use the
twos-compliment method. Negate the number and add one.

0 new messages