Next: Advanced
algebraic operations on Up: Commands Previous: Operations on modular
Internally ALG48 does all its calculations using
unlimited precision integers. These unlimited precision integers
are represented by hexstrings (binary integers) of variable
length (not limited to 64 bits), with a sign-magnitude
format (one sign nibble and a variable length unsigned
magnitude). For instance, the number 1 is represented by the
two-nibble hexstring #01h, whereas the number is represented by the eighteen-nibble hexstring #0100..0h.
Negative numbers are identical except for the sign nibble which
is set to F. For instance, the number -1 is represented
by the two-nibble hexstring #F1h and
is represented by the eighteen-nibble
hexstring #F100..0h. Finally, zero is represented by the
one-nibble hexstring #0h. Note that the two-nibble
hexstring #F1h does not represent the same
number as the three-nibble hexstring #0F1h (which
represents the number 241).
You can use ALG48 to do unlimited precision integer arithmetic directly by using the basic operation commands (except AINV) with binary integer arguments (or one binary integer and a real number). For example
#2 <enter> 65 APOW
computes the exact value of . Note,
however, that the HP48 will only display the value of
the 64 (or whatever your binary word size currently is)
lowest-significant bits of long hexstrings. Therefore, in the
example above, the result will be displayed as #0h since
the lowest 64 bits are all zeros. To overcome this problem, ALG48
provides the command Z<->S that converts a
variable length hexstring into a (character) string giving its
value in decimal, or vice versa. Thus typing
#2 <enter> 65 APOW Z<->S returns "3689348814711903232"
which is the exact value of . As an
additional example, the following little user-RPL program
computes the exact factorial of its single real argument, and
returns it as a string:
<< #1h 1 ROT FOR i i AMUL
NEXT Z<->S >>
Running it with 100 as argument gives
As a typing short-cut, ZS is an alias name for the Z<->S command.
Next: Advanced
algebraic operations on Up: Commands Previous: Operations on modular