▼
Posts: 260
Threads: 32
Joined: Jul 2005
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?
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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)
▼
Posts: 260
Threads: 32
Joined: Jul 2005
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
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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.
▼
Posts: 260
Threads: 32
Joined: Jul 2005
Thank you! A brilliant idea, I will write a program and publish it in the software library!
Thank you Luiz! Klaus
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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)
▼
Posts: 260
Threads: 32
Joined: Jul 2005
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!!!
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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)
▼
Posts: 88
Threads: 10
Joined: Jan 1970
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)
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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
▼
Posts: 260
Threads: 32
Joined: Jul 2005
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
▼
Posts: 464
Threads: 10
Joined: Jan 2005
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!
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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.
▼
Posts: 464
Threads: 10
Joined: Jan 2005
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 !!!
|