HP Forums
HP-11C FRAC & INT - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: HP-11C FRAC & INT (/thread-21537.html)



HP-11C FRAC & INT - Gamo - 04-01-2024 10:02 AM

The HP-55 doesn't have FRAC and INT functions and I'm happen to see some
program example from HP-55 User's Manual that program the fractional and
integer part routine in program.

So I just try this out on the HP-11C to see how it work with this program
it will only work on "Positive Integer"

Procedure:

LBL A for FRAC
LBL B for INT

Program:
Quote:LBL A
ENTER ENTER GSB1 1 - - 1 X≤Y GTO 0 R↓ RTN

LBL B
LBL 1 EEX 9 + LSTx - RTN LBL 0 - RTN

Example: FIX 9

¶ display 3.141592654 [A] display 0.141592654

7 e^x display 1096.633158 [B] display 1097.000000

To find the remainder of the division of 18811 ÷ 133

18811 [ENTER] 133 [÷] display 141.4360902

While result on display press [A] display 0.436090200

While result on display press 133 [x] display 57.9999660

While result on display press [B] display answer 58

The remainder is 58

Gamo 4/2024


RE: HP-11C FRAC & INT - Thomas Klemm - 04-01-2024 02:04 PM

(04-01-2024 10:02 AM)Gamo Wrote:  7 e^x display 1096.633158 [​B] display 1097.000000

That is rounding it to the next integer.

If you really want to implement INT you can use:
Code:
   001 { 42 21 11 } f LBL A
   002 {       36 } ENTER
   003 {    32 12 } GSB B
   004 {       30 } -
   005 {    43 32 } g RTN
   006 { 42 21 12 } f LBL B
   007 {       48 } .
   008 {        5 } 5
   009 {    42 20 } f x>y
   010 {    43 35 } g CLx
   011 {       30 } -
   012 {       26 } EEX
   013 {        9 } 9
   014 {       40 } +
   015 {    43 36 } g LSTx
   016 {       30 } -

Example

7 ex
GSB B

1,096.000000


Caveat: This doesn't work for numbers bigger than 9,999,999,990.
On the other hand, these are already integers.