Sunday, July 31, 2016

Casio fx-3650p and fx-50FH: Integer Parts and Fractional Parts

Casio fx-3650p and fx-50FH: Integer Parts and Fractional Parts

Programming can be a pain if the popular functions INT (integer part) and FRAC (fractional part) are not present.  Here is a sample routine to extract the parts for the Casio fx-3650p and fx-50FH.  The key is to take advantage of:

* Switching to and from Fix 0 mode and
* Using the RND (round the number in the display) to the number of decimal places specified in the Fix mode

You can modify or incorporate the sample code to fit your needs.  This basic scheme should work on any programming calculator with at least 2 variable registers and the RND function.   Due to the syntax of RND, the programs for the fx-3650p and fx-50FH are slightly different.  

The following results will be stored in the following variables:
A = ABS(A)
B = INTG(A)
C = FRAC(A)
M = SGN(A) 

Casio fx-3650P:  Integer and Fractional Parts  (53 steps)

?→A:  \\ ask for a number 
A ÷ √( A ²) → M:  \\ sign of A
√( A ²) → A:  \\ absolute value
Fix 0:  \\ go into Fix 0 mode
RND:  \\ round answer in the display
Ans → B:
Norm 1:  \\ back into floating mode
B > A ⇒ B - 1 → B:  \\ adjust B if necessary
BM → B ◢  \\ integer portion
AM - B → C  \\ fractional portion

Casio fx-50FH: Integer and Fractional Parts  (51 steps)

?→A:  \\ ask for a number 
A ÷ Abs(A) → M:  \\ sign of A 
Abs(A) → A:  \\ absolute value
Fix 0:  \\ go into Fix 0 mode
Rnd(A) →  B :  \\ round A and store in B
Norm 1:  \\ back into floating mode
B > A ⇒ B - 1 → B:  \\ adjust B if necessary
BM → B ◢  \\ integer portion
AM - B → C  \\ fractional portion


Test 1:   13.913
Results:
B = 13 (integer portion)
C = 0.913 (fractional portion)

Test 2: -741.185
Results:
B = -741 (integer portion)
C = -0.185 (fractional portion)

If you find this helpful and can incorporate this routine into future programs.  To those calculators with fractional  and integer part commands: you're awesome.  

Eddie

This blog is property of Edward Shore, 2016