16c functions


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


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?


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)


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


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:
Or, if you want to keep a copy of the original X-register contents in Y-register:
So, without having written the program, given the number in X-register, I'd suggest the following steps (MUST BE CHECKED):
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.


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

Thank you Luiz! Klaus


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)


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!!!


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)


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:


See you,


(1234 to remove)


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!)




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


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!


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.


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 3,322 12-07-2013, 01:26 PM
Last Post: Eelco Rouw
  [41CL] New Extra Functions version Monte Dalrymple 0 513 11-08-2013, 04:32 PM
Last Post: Monte Dalrymple
  HP Prime: in need of help with defining functions Alberto Candel 14 1,914 10-27-2013, 10:48 AM
Last Post: Alberto Candel
  Shiny new 16C! Keith Midson 7 1,153 10-27-2013, 02:22 AM
Last Post: Keith Midson
  HP Prime spreadsheet functions SanS 0 1,054 10-04-2013, 04:23 AM
Last Post: SanS
  Stats functions on the HP34S Nicholas van Stigt 5 899 09-24-2013, 02:45 AM
Last Post: Nick_S
  Trig Functions Howard Owen 11 1,564 09-16-2013, 02:53 PM
Last Post: Fred Lusk
  50g piecewise functions Kurt Fankhauser 6 989 09-15-2013, 08:01 PM
Last Post: Kurt Fankhauser
  Missing functions on the HP Prime!!!??? :-( Namir 6 973 08-22-2013, 08:40 AM
Last Post: Gilles Carpentier
  HP41 Functions Address Table (F.A.T.) Antoine M. Couëtte 6 944 07-21-2013, 02:48 AM
Last Post: Antoine M. Couëtte

Forum Jump: