Post Reply 
Problem with HEAD & TAIL Programmes on HP 33s
09-01-2022, 03:59 PM (This post was last modified: 09-02-2022 10:19 AM by Gerald H.)
Post: #1
Problem with HEAD & TAIL Programmes on HP 33s
Previously I have used this programme

Code:
1.    LBL H
2.    x=0?
3.    RTN
4.    LOG
5.    FP
6.    10^x
7.    IP
8.    RTN

H: LN = 24

to return the leading digit of a natural number.

Quite correctly the programme returns a false answer for large input, eg 999,999,999,999.

The following programme solves that problem but is markedly slower

Code:
1.    LBL X
2.    STO N
3.    CLx
4.    10
5.    x<> N
6.    RCL/ N
7.    IP
8.    x≠0?
9.    GTO X
10.    CLx
11.    LASTx
12.    RCL*N
13.    RTN

X: LN = 51

Both programmes preserve the stack.

Has anyone got a better solution?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Problem with HEAD & TAIL Programmes on HP 33s - Gerald H - 09-01-2022 03:59 PM



User(s) browsing this thread: 1 Guest(s)