(28/48/50) Base Conversion Programs
|
01-02-2023, 07:21 PM
(This post was last modified: 02-14-2023 05:48 PM by John Keith.)
Post: #1
|
|||
|
|||
(28/48/50) Base Conversion Programs
These two simple programs convert integers to and from lists of digits in any base. The integers, the base and the digits may be positive or negative.
The first program takes an integer on level 2 and an integer base on level 1 and returns the digits as a list. I call the program I→DL to avoid conflict with the similar ListExt command I→BL. In exact mode on the HP 49 and 50, the size of the integer and the base are limited only by memory. Important note: If the base is positive, the level 2 integer must be positive, otherwise the program will crash with an Insufficient Memory error. Code:
Also an approximate version for the HP-28 and 48. Code:
The next program takes a list of integers on level 2 and the base on level 1 and returns an integer. The base may be negative or complex, and on the 49 and 50 it can be symbolic- given 'X' as the base it will return a polynomial in X. It runs without modification on any RPL calculator. Called DL→I for reason given above. Code:
A shorter version for HP 48G and later: Code:
Updated 1/03/2023 with improved I→DL programs. Updated 1/04/2023 with additional note and program. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(28/48/50) Base Conversion Programs - John Keith - 01-02-2023 07:21 PM
RE: (28/48/50) Base Conversion Programs - John Keith - 02-14-2023, 05:54 PM
RE: (28/48/50) Base Conversion Programs - Gerald H - 02-15-2023, 03:58 AM
|
User(s) browsing this thread: 1 Guest(s)