HP Forums

Full Version: (12C) Fractional Part Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The HP-55 doesn't have FRAC and INT funtions and I'm happen to see some
program example from HP-55 User's Manual that program the fractional
part routine in program.

Try this Fractional Part routine and it work as expected on HP-12C
Since this type of problem still exist on some programmble calculator that doesn't have
these funtion, couple friend of my have ask me about this type of problem before and I
didn' t know any good solution yet, until now.

This FRAC functions routine only work on "Positive Integer"

Example: FIX 9

2 [√X] display 1.414213562

[R/S] display 0.414213562
--------------------------------
355 [ENTER] 113 [÷] display 3.141592920

[R/S] display 0.141592920

Program: FRAC function
Quote:01 ENTER
02 ENTER
03 EEX
04 9
05 +
06 LSTx
07 -
08 1
09 -
10 -
11 1
12 X≤Y
13 GTO 16
14 Rv // Roll Down
15 GTO 00
16 -

Remark: Program line 03 to 07 by itself canbe use as INT function.

Gamo 1/3/2020
Doesn't the 12C have a FRAC function built in?
Joe Horn

The HP-12C got these functions.
Just demonstrate this routine on 12C
as an example, so that people who got other
HP programmable calculator that doesn't have
this function can adapt to it. Also HP-55 manual
use this algorithm so it must be good to share for
those who interested.

Gamo
Aha, I understand now. Thanks, Gamo!
(01-03-2020 05:34 AM)Gamo Wrote: [ -> ]Remark: Program line 03 to 07 by itself canbe use as INT function.

I think it is more like ROUND function.
We may go for FLOOR instead, remove the branching code.

Quote:01 ENTER
02 ENTER
03 .
04 5
05 -
06 2
07 EEX
08 9
09 +
10 LSTx
11 -
12 -

For -1E9 < v ≤ 8E9: above defined FRAC(v) as v - FLOOR(v) = v - (ROUND(v - 0.5 + 2E9) - 2E9)

Example:
123.45 R/S            → 0.45
123.45 CHS R/S     → 0.55
Reference URL's