16c functions



#15

The 16c is my favorite HP:
It can do all kind of bit manipulation, a feature I use often, but the reason why I like it best is that the [CHS] and [EEX] keys are in the right position for scientific calculations. However this might be subjective to me.
When using this calc in integer mode, I miss two functions: log (or ld) and x^y (or 2^x).
My program for 2^x is:

Label 2 43,22, 2

cf 4 43, 5, 4

1

x<>y 34

RLCn 43 E

RTN 43 21

(it clears the carry flag and rotates the number 1 Stack[x]x times left.

For the ld, I can only come up with iterative solutions (shift stack[x] right until it is 0 and count the loops) or (while 2^y < stack[x] increment y by one)
Can anyone come up with a smarter solution?


#16

Hi, Klaus;

let me see if I got it correctly: by ld you mean a generic logba or a base-2 log, i.e., log2a. If I understood it well, you want the counterpart for x^2; is that correct?

Thanks and forgive me not getting it correctly. I just want to help the way you want to.

Best regards.

Luiz (Brazil)


#17

ld means the counterpart for 2^x, log2(x). Since we are dealing with integer mode, it is the answer for the question "How many binary digits (places) has the number?".

Thank you for your interest! Klaus


#18

Hi, Klaus;

I have not my HP16C in hands, but I tried to reason about the facts. Given any integer in X-register (stack[x]), if you perform [LJ] you'll justify it to the left and the bit-counting is placed in X-register. Given the word size, the number of digits in this integer is:

ld(x) = (current WS) - (bit counting)
The problem is that there is no way to recall current word size, but it can be computed with:
1
LJ
LSTx
+
Or, if you want to keep a copy of the original X-register contents in Y-register:
1
LJ
x<>y
RL
+
So, without having written the program, given the number in X-register, I'd suggest the following steps (MUST BE CHECKED):
LJ
1
LJ
x<>y
RL
+
x<>y
-
If things are as expected, the original number remains left-justified in Y-register (stack[y]). Hope this works and give you a solution.

Best regards.

Luiz (Brazil)

Edited: 15 June 2005, 2:53 p.m.


#19

Thank you! A brilliant idea, I will write a program and publish it in the software library!

Thank you Luiz! Klaus


#20

Hi, Klaus;

did it work correctly? I assume so (I did not test it yet).

Please, let us know as you have your program ready and published.

Best regards.

Luiz (Brazil)


#21

I wanted to keep the "memory footprint" small, so the user has to assert a sufficient wordsize. Here is my program:

001-43,22, A Label A

002- 43 A LJ

003- 1 1

004- 43 A LJ

005- 34 x<>y

006- 33 Roll down

007- 34 x<>y

008- 30 -

009- 43 21 ReTurN


010-43,22, 2 Label 2

011- 1 1

012- 34 x<>y

013- 42 E RotateLeft n

014 43 21 ReTurN


Usage: To calculate 2^8, enter [8] [GSB] [2]. The display then shows 256. How many bits do we need to store 1024? Enter [1][0][2][4] [GSB][A]. The display then shows 10. That means, 2^10 = 1024, so we need 11 bits to store 1024 (as the first bit values 2^0).

Thank you Luiz for the ld-program! I now consider the instruction set of my 16c complete!!!


#22

I'm glad you made it. I'm not sure if this German expression means the same in English, but it's worth a try: Du bist willkommen, mein Freund!

Best regards.

Luiz (Brazil)


#23

Hi Luiz,

Just a little help to your foreign language learning eagerness, while Klaus himself doesn't reply to you:

Should be 'bitte schoen'

No, I don't know German. I just asked my 16-year old son who's started to study German only three weeks ago. He was taught this when he made that same mistake :-)

More German greetings at:

http://www.duess.jis.de/~mori/lifeE.html

See you,

Gerson.

(1234 to remove)


#24

I didn't see that comming... In fact, I completely forgot about that. Please, tell your son 'Viele Danke' for me and thanks for the interesting link (time to resume my German classes.. quickly!)

Cheers.

Luiz


#25

Hi Luiz,

we also say "gern geschehen" or "war mir ein Vergnügen", which means something like "it was a pleasure for me".

In spring I visited your country and found out that people in South America are politer than european people, so you surely have more expressions for "Bitte schön".

Obrigado! Klaus


#26

Hi all!

And these impolite Europeans made their way to the far East Japan!

Some of them were portuguese missionaries...

And they imported the word "Obrigado" in Japan...

And this was progressively adopted to give the japanese word "Arrigato" which means "thank you"!

Have a nice day!


#27

Hi, Etienne;

just to ask you if you received an e-mail of mine, dated June 14th. If not, let me know because I have a copy of it and I can re-send it to you.

Best regards.

Luiz (Brazil)

123456 to remove

PS: many Brazilians are not aware of this fact regarding 'Arrigato'. AFAIK (and been told about), the Japanese could only 'thank' by slightly bending their bodies forward, so they had no specific word for thanking.


#28

Friendly greetings from France, Luiz!!

Well...shame on me...I have got your message from June 4th fine!!!

...and I have NO excuse for not answering earlier...sorry...

You should have received my answer by now!

Arrigato for all and a big bunch of apologies from

Lazy Etienne !!!


Possibly Related Threads...
Thread Author Replies Views Last Post
  Bought a 16C to compensate a little Eelco Rouw 23 2,486 12-07-2013, 01:26 PM
Last Post: Eelco Rouw
  [41CL] New Extra Functions version Monte Dalrymple 0 383 11-08-2013, 04:32 PM
Last Post: Monte Dalrymple
  HP Prime: in need of help with defining functions Alberto Candel 14 1,496 10-27-2013, 10:48 AM
Last Post: Alberto Candel
  Shiny new 16C! Keith Midson 7 865 10-27-2013, 02:22 AM
Last Post: Keith Midson
  HP Prime spreadsheet functions SanS 0 823 10-04-2013, 04:23 AM
Last Post: SanS
  Stats functions on the HP34S Nicholas van Stigt 5 696 09-24-2013, 02:45 AM
Last Post: Nick_S
  Trig Functions Howard Owen 11 1,162 09-16-2013, 02:53 PM
Last Post: Fred Lusk
  50g piecewise functions Kurt Fankhauser 6 724 09-15-2013, 08:01 PM
Last Post: Kurt Fankhauser
  Missing functions on the HP Prime!!!??? :-( Namir 6 724 08-22-2013, 08:40 AM
Last Post: Gilles Carpentier
  HP41 Functions Address Table (F.A.T.) Antoine M. Couëtte 6 711 07-21-2013, 02:48 AM
Last Post: Antoine M. Couëtte

Forum Jump: