# HP Forums

Full Version: LOG for HP 12C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is a LOG program for HP 12C

Find the LOG in any base of any number: LOGь X: X > 0, b > 1

01 LN
02 R↓
03 LN
04 R↓
05 R↓
06 R↓
07 ÷
08 GTO 00

Example:
LOG₃ 9 = 2 9 ENTER 3 R/S 2
LOG₈₁ 3 = ⅟₄ 3 ENTER 81 R/S 0.25
LOG₁₀₀₀ 10 = ⅓ 10 ENTER 1000 R/S 0.33

Gamo
Here is my version. Not exactly faster, better or more accurate, only three steps shorter:

01 LN
02 1/x
03 y^x
04 LN
05 GTO 00

Best regards,

Gerson.

--------

PS:

Or, in a more conventional way, but one step longer:

01 LN
02 x<>y
03 LN
04 /
05 1/x
06 GTO 00
EDIT: Rats, Gerson was faster and shorter. :-) Is either method more accurate?

Good idea!

LN
X<>Y
LN
X<>Y
/
GTO 00
(08-30-2017 02:07 AM)Gene Wrote: [ -> ]How about:

LN
X<>Y
LN
X<>Y
/
GTO 00

Better than my 6-step version above (register swap is faster than 1/x). Faster than the 5-step one too!

Gerson.
Thanks for more alternative ways of LOG program.

Just wondering about the compute functions like 1/x or y^x will take more time to calculate than just using Rv or X<>Y

Gamo
(08-30-2017 04:22 AM)Gamo Wrote: [ -> ]Just wondering about the compute functions like 1/x or y^x will take more time to calculate than just using Rv or X<>Y

Rv and x<>y are simple operations involving transfer of contents between internal registers. y^x alone requires a call to LN and another to e^x, both transcendental functions that take a lot a shift and add operations plus access to external tables in ROM. On slow calculators like the original HP-12C the difference in speed is quite noticeable, even without a stopwatch.
The choice of which solution to use depends on what amount of free memory you have. The five-step version would make sense if those were the last remaining free steps on you 12C.

Gerson.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :