Post Reply 
Programming the INT and FRAC functions
01-08-2016, 08:50 AM
Post: #17
RE: Programming the INT and FRAC functions
Well, i just tried something on the 11c (which has int and frac, but this might similarly work on other calcs, so i tried it anyway).

This will only work if you usually use the same display mode, e.g. FIX 3.

For INT:
Code:
42,21,11   LBL A
   42, 2   ->H.MS
   42, 2   ->H.MS
42, 7, 0   FIX 0
   43,34   RND
42, 7, 3   FIX 3 (or whatever your disp mode is)
   43,32   RTN

Explanation:
the two ->H.MS bring the fractional part below 0.5 so that the number is always rounded down. FIX0 rounds the number in the display, RND rounds the number internally to the displayed value, and FIX3 brings back the old display setting (ad has to be replaced by your favourite display mode).

For FRAC:
Code:
42,21,12   LBL B
      36   ENTER
   32,11   GSB A
      30   -
   43,32   RTN

Explanation:
The number gets copied to y, then the INT function is run. afterwards the integer part is subtracted from the number in y, so that only the fractional part stays displayed.

This works well and needs 12 steps. Still it only works only with one display mode (but as i personally mostly use ENG3 i can live with that). Also, the T register gets destroyed by using FRAC.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming the INT and FRAC functions - damaltor - 01-08-2016 08:50 AM



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