2023 in Base 37
01-06-2023, 08:25 PM
Post: #7
 John Keith Senior Member Posts: 1,019 Joined: Dec 2013
RE: 2023 in Base 37
Just for fun, here are two programs for converting integers to and from strings representing the integers in any base up to base 62. The programs are for the HP49/50 with the ListExt Library.
In the strings:

The numbers 0..9 map to themselves
The numbers 10..35 map to A..Z
The numbers 36..61 map to a..z

The first program I→STR take an integer n on level 2 and an integer b on level 1 and returns a string representing n in base b.

Code:
 \<< I\->BL NL\->S     { 36. 61. 61. } CHR+     { 10. 35. 55. } CHR+     { 0. 9. 48. } CHR+ \>>

The next program STR→I does the inverse, taking a string on level 2 and b on level 1.

Code:
 \<< SWAP     { 48. 57. -48. } CHR+     { 65. 90. -55. } CHR+     { 97. 122. -61. } CHR+     S\->NL SWAP BL\->I \>>

For example, the input

257175174
62
I→STR

returns "HP50g"
 « Next Oldest | Next Newest »

 Messages In This Thread 2023 in Base 37 - Joe Horn - 01-06-2023, 12:21 PM RE: 2023 in Base 37 - pier4r - 01-06-2023, 12:58 PM RE: 2023 in Base 37 - John Keith - 01-06-2023, 06:34 PM RE: 2023 in Base 37 - Maximilian Hohmann - 01-06-2023, 01:05 PM RE: 2023 in Base 37 - toml_12953 - 01-06-2023, 08:07 PM RE: 2023 in Base 37 - pier4r - 01-06-2023, 07:58 PM RE: 2023 in Base 37 - John Keith - 01-06-2023 08:25 PM RE: 2023 in Base 37 for the 28's users - C.Ret - 01-07-2023, 11:17 AM RE: 2023 in Base 37 - pier4r - 01-07-2023, 11:39 AM RE: 2023 in Base 37 - Gerald H - 01-07-2023, 04:06 AM RE: 2023 in Base 37 - brouhaha - 01-07-2023, 06:23 AM RE: 2023 in Base 37 - mfleming - 01-07-2023, 09:59 PM RE: 2023 in Base 37 - John Keith - 01-20-2023, 07:41 PM

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