The Museum of HP Calculators

HP Forum Archive 09

[ Return to Index | Top of Index ]

HP-16C Question
Message #1 Posted by John Smith on 19 Sept 2002, 6:16 a.m.

Hi everybody,

Just a question for all those amazingly knowledgeable HP-programming experts in this Forum. I've recently got a brand-new HP-16C, manuals and all, and have tried to program a very simple calculation, for test purposes but mostly for fun.

The problem is, I know next to nothing about this particular machine, which has a very different function set from, say, an HP-11C or 15C, and though what I'm trying to do seems pretty simple, I can't figure out how to do it nor can make any sense of reading the manuals.

The question is: I'm trying to perform a pure floating point calculation (not octal, hexadecimal, binary or whatever, just plain floating point), but there's a time when I need just the INTeger part of a floating point value. In an HP-11C or 15C or almost any other model, I would simply use the built-in INT function, but either I'm too dumb to notice, or there seems to be no INT function on the 16C !

Now, I'm sure there must be some easy way of doing just that, getting the INTeger part of a floating point value, and then go on performing more floating point computations with that value and the rest of the 4-level floating point stack unaffected.

Can it be done ? How ? I just can't believe it can't, and I'd rather blame myself for failing to see the probably ultra-obvious correct procedure.

Any help would be greatly appreciated, many thanks in advance, and excuse me if my question is way too silly.

      
Re: HP-16C Question
Message #2 Posted by Vieira, Luiz C. (Brazil) on 19 Sept 2002, 11:58 a.m.,
in response to message #1 by John Smith

Hi;

you're no dumb at all. There is no INT function available in the 16C's Floating Point repertoire. If you have the Owner's Handbook, get Section 5. All available Floating Point resources are described there.

And now you teased me. I'll work on this subject soon, but I want you to check for this:

- go to Floating Point and store a number (say, 234.4567) in R0 ([STO] 0) - clear X-register and go back to integer hexadecimal ([HEX]) - recall R0 and inspect its contents

you'll see the two rightmost digits are the exponent of ten, and the leftmost digits are the mantissa. As you are in HEX mode, you see that the numbers are stored in BCD coding, and you should "mask" the n leftmost digits, being n the exponent of ten (in our case, 2), remove the rest of the mantissa and save the so called "INT" representation back to R0. I believe it will need about 10-15 program steps. If you wanna try, tell me. I'll try this weekend.

Success.

      
Now, my questions are:
Message #3 Posted by Vieira, Luiz C. (Brazil) on 19 Sept 2002, 5:07 p.m.,
in response to message #1 by John Smith

Hi;

I read your post again and you mention a bradn-new HP16C; my first question is: where did you get this?

You also mention "manuals" two times in your post. The second question is: which is the other namual than the Owner's Handbook?

Thanks. (any success already?)

      
INT function on a HP without it
Message #4 Posted by Nenad Vulic (Croatia) on 20 Sept 2002, 2:58 a.m.,
in response to message #1 by John Smith

Try this (it works for positive floating point numbers in X-register):

EEX; 9; +; LAST X; -

It can also replace RND function if you replace 9 by 9-N, where N is the number of digits after the decimal point you want to preserve.

I have used this a lot on my HP33E when I was in high school (more than 20 years ago).

Nenad

            
Re: INT function on a HP without it
Message #5 Posted by Les Bell on 20 Sept 2002, 3:12 a.m.,
in response to message #4 by Nenad Vulic (Croatia)

Neat, but there's no EEX on a 16. <g> It really *is* a very different beast.

Best,

--- Les Bell, CISSP [http://www.lesbell.com.au]

                  
Re: INT function on a HP without it
Message #6 Posted by Les Bell on 20 Sept 2002, 3:25 a.m.,
in response to message #5 by Les Bell

Bzzzt! Earth to Les: Of *course* there's an EEX button on the 16, it's just f-CHS, where you can't see it in a dark office. . . .

Sorry, Nenad - your technique will work just fine.

Best,

--- Les Bell, CISSP [http://www.lesbell.com.au]

            
This is a solution!
Message #7 Posted by Vieira, Luiz C. (Brazil) on 20 Sept 2002, 6:22 a.m.,
in response to message #4 by Nenad Vulic (Croatia)

HI, Nenad;

What to say? Simple procedure, brilliant solution.

Cheers.

                  
Certainly ! Thanks to both of you
Message #8 Posted by John Smith on 20 Sept 2002, 10:42 a.m.,
in response to message #7 by Vieira, Luiz C. (Brazil)

Thanks to both of you for your imaginative solutions. Adding a large number will certainly work, though I will have to take into account the sign of the numbers, as they can be negative at that stage and if so I would need to subtract instead of adding.

I was thinking that perhaps there was some way of changing to some integer mode, do some operation with the number, then return to floating point with the truncated result, but could find no way to do it.

As for Luiz's question, I got the machine while visiting a new acquaintance to whom I told casually I was interested in HP calcs. Much to my astonishment, she then produced the still boxed machine from a drawer where it had been stored for the last 20 years or so. Everything was unused, brand-new, even the Owner's Handbook was still shrink-wrapped. Not wishing to open it up, I got a copy of a book from the "Easy Course ..." series, but couldn't find any reference to an INT function anywhere. That particular book is large, heavy, and makes fun reading, but probably is no substitute for the manual proper.

Again, thanks to both of you, you've been most helpful.

                        
Re: Certainly ! Thanks to both of you
Message #9 Posted by Vieira, Luiz C. (Brazil) on 20 Sept 2002, 10:52 p.m.,
in response to message #8 by John Smith

Hi;

If you need to keep your original manual as it is, let me know. I'll scan the original (I have one) and send you the images.

If I have one HP16C Owner's Manual packed, I'd do what is needed to keep it this way.

Cheers. (lucky guy...)

            
Re: INT function on a HP without it
Message #10 Posted by Werner Huysegoms on 23 Sept 2002, 1:39 a.m.,
in response to message #4 by Nenad Vulic (Croatia)

I'm afraid that's RND, not INT. For INT, do: .5 - EEX 9 + LASTX - And even then, it does not always yield the correct answer due to 'unbiased rounding':

1. 'INT' -> 0. 2. 'INT' -> 1.

But I don't have a HP on which to test that. My 42S has unbiased rounding.

Werner Huysegoms

                  
Re: INT function on a HP without it
Message #11 Posted by Nenad Vulic (Croatia) on 23 Sept 2002, 10:56 a.m.,
in response to message #10 by Werner Huysegoms

You are right, Werner, thank you. I have to improve it. If you need an INT (not a RND) you may use the following program (17 steps):

*LBLA; ENTER; ENTER; EEX; 9; +; LASTx; -; x>y; 1; 0; ENTER; 1; 0; /(divide); -; RTN

This was tested on HP11C and works for positive numbers. The program contains only the functions available on a HP16C (as seen from it's photo, not a real one:)


[ Return to Index | Top of Index ]

Go back to the main exhibit hall