HP Forums

Full Version: (12C) Decimal Expansion of a Fraction
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HP-12C program to give the decimal expansion of a fraction to
as many decimal places as desired.

-----------------------------------------------------------------

Procedure:

Enter the numerator [R/S] and the denominator, both whole number [R/S] and keep

pressing [R/S] giving next digit in the decimal expansion. Record these on paper if you wish.

Note that the decimal point is not diplayed by the calculator.

Press [PRGM] for each new problem.
-------------------------------------------------------------------
Code:

01 STO 1
02 R/S
03 STO 2
04 RCL 1
05 RCL 2
06  ÷
07 INTG
08 STO 0
09 RCL 1
10 RCL 0
11 RCL 2
12  x
13  -
14 EEX
15  1
16  x
17 STO 1
18 RCL 0
19 R/S
20 GTO 04

Example: FIX 0

355 / 113 = x.xxxxxxx...........

[PGRM] 355 [R/S] 113 [R/S]....... 31415929203539823008849557522123893..........

Remark:

This program can be modify further to show 10 decimal expansion digits at a time
instead of one at a time but I havn't do this yet. If someone got an idea or ways
to do it you're welcome. Thank You

Gamo
Nice !

I being in trouble when using a HP-12C, I am a bit more trained on HP-15C.

I still succeed in producing a shorter code than yours.

But the usage is a bit different; you have to enter the two values in the stack before running the program :

Code:
P/R
f CLEAR PRGRM
00-     
01-     44 0     STO 0
02-     42 0   f FIX 0
03-       34     x><y
04-       36     ENTER
05-       36     ENTER
06-     45 0     RCL 0
07-       10      ÷ 
08-    43 25   g Intg
09-       31     R/S
10-    45  0     RCL 0
11-       20      × 
12-       30      - 
13-        1      1
14-        0      0 
15-       20      × 
16-43,33 04      GTO 04
P/R

usage:
Code:
517656 [ENTER] 190435 [R/S]    [R/S] [R/S] [R/S] [R/S][R/S] ...
          2 ... 7 ... 1 ... 8 ... 2 ... 8 ... 1 ... 8 ... 2 ... 8 ... 4 ... 6 ...

Only register R0 is used; the trick is to use a double ENTER to kept a copy of the numerator in the stack, this allows to compute the remainder straightforward and of course the Goto repeat this trick forever.
Reference URL's