RPL Programming Examples 2-23
nBASE program listing
Program: Comments:
"!
!3!O7!8!K=4!DYB2!8!K=4!!
KOE7!
Clear flag 1, round both arguments to
integers and recall flag settings.
!#!%!G!*!
Store the base, number and flag settings
in local variables.
!!"!
Begin the outer local variable structure.
!!!D:4!G!EL>!%!EL>!,!
Sets “standard” display mode and
computes the ratio of the common
logarithms of number and base.
!!!38!K=4!
Rounds result to remove imprecision in
last decimal place.
!!!62!G!8!
Find the integer part of log ratio, recall
the original number, and initialize the
counter variable k for use in the
DO...UNTIL loop.
!!!#!t!o!|!
Store the values in local variables.
!!!!"!
!!!!!II!
!!!!!4L!
!!!!!!+o+!<NBE!%!t!
!!!!!!+|+!<NBE!0!W!
Begin inner local variable structure, enter
an empty string and begin the
DO...UNTIL...END loop.
Compute the decimal value of the
(i
– k) th position in the string.
!!!!!!452H!ML4!
Makes a copy of the arguments and
computes the decimal value still
remaining that must be accounted for by
other positions.
!!!!!!67!452!8![[!
!!!!!!!+o+!<NBE!%!A!
!!!!!!B=4!
!!!!!!:;<=!3!D7!
Is the remainder zero and m
≥
b?
If the test is true, then set flag 1.
!!!!!!<=4!+o+!D:L!
!!!!!!,!62!
Store the remainder in m. Compute the
number of times the current position-
value goes into the remaining decimal
value. This is the “digit” that belongs in
the current position.
!!!!!!67!452!38!A!
!!!!!!:;<=!QQ!!
!!!!!!<ED<!aR!!
!!!!!!<=4!'!O;K!
Is the “digit”
≥
10?
Then convert the digit into a alphabetic
digit (such as A, B, C, …).
!!!!!!'!+|+!3!D:L'!
Append the digit to the current result
string and increment the counter variable
k.