We are looking for a function that converts base 10 numbers to base 36 numbers (using numbers and letters to represent base 36 numbers), and also another function to convert base 36 text
Example1 - Convert base 10 to base 36 >> enter base 10 number int(3634) and get base 36 text string "2SY"
Example2 - Convert base 36 to base 10 >> enter base 36 text string("A2J") and get base 10 number int 13051
Does anyone have an idea where we can start from?
Discussion posts and replies are publicly visible
For anyone who's interested, I was able to whip up this Appian expression rule last night, which uses 100% out-of-box functionality. In it, a user can pass any valid integer, as well as any base (between 2 and 36), and get the resulting conversion in a string. It performs fairly well, converting some of the largest allowable Appian integers into base 36 in only 2ms.
ri!base > 36,
ri!base < 2
local!charset: left("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", local!base),
local!powerBase: log(ri!integer, local!base),
local!numCharacters: ceiling(local!powerBase) + 1, /* the resulting number will need up to this many characters */
local!placeValue: ri!integer / (local!base ^ (fv!item)), /* requires zero-indexed list */
local!charIndex: floor(mod(local!placeValue, local!base)),
local!placeValue < 1,
/* debug -- uncomment the following lines to see earlier calculated values */
/*&char(10) & "power base: " & local!powerBase*/
/*&char(10)& "places: " & local!numCharacters*/
To convert back from a given base to base10 would just require an expression rule that does the reverse of this, which IMHO would actually be easier (edit: i've written this too and posted it below).
© 2022 Appian. All rights reserved.