hexatridecimal or base 36
Moderators: chulett, rschirm, roy
hexatridecimal or base 36
Hi All,
Part of a requirement I have is to store a number in hexatridecimal format (also known as base 36). Do you know if there are any built-in functions/routines in DataStage that will allow me to do this... or will it need to be something bespoke?
Many thanks in advance.
S
Part of a requirement I have is to store a number in hexatridecimal format (also known as base 36). Do you know if there are any built-in functions/routines in DataStage that will allow me to do this... or will it need to be something bespoke?
Many thanks in advance.
S
why did you multiply 3 and 16 ? Decimal is base 10, binary is base 2, hexatridecimal or as you correctly pointed sexatrigesimal is base 36(it uses 0-9 and A-Z). Funny names thoughchulett wrote:I would wager you'll need to roll your own conversion.
Before reading this, I thought it was a typo as 3x16 is 48 not 36... so, sexatrigesimal?
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
Spot on!chulett wrote:I would wager you'll need to roll your own conversion.
Before reading this, I thought it was a typo as 3x16 is 48 not 36... so, sexatrigesimal?
From:Wikipedia wrote:The most common latinate name for base 36 seems to be hexatridecimal, although sexatrigesimal would arguably be more correct."
http://en.wikipedia.org/wiki/Base_36
Cheers,
S
Code: Select all
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lenChars = LEN(chars)
;! Check if ok to convert to this base...
If nbase < 2 or nbase > lenChars Then
Return('')
End
r = ''
newNumber = ''
;! r contains offset of char that was converted to new base
Loop
r = MOD(num,nbase)
newNumber = chars[r+1,1]:newNumber
num = INT(num/nbase)
While num >= nbase Do repeat
;! Final number to convert
Ans = (chars[num+1,1]:newNumber)
Honest critiques welcome
Regards,
S
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There will be some upper limit to the size of numbers you can convert using ordinary arithmetic, depending on your EXACTNUMERIC setting.
For numbers larger than this you can use "string math" (SAdd(), SMui(), SSub() and SDiv() functions). You need to build a "remainder" function out of SDiv() and SSub() functions.
Did you ask WHY there is this requirement?
For numbers larger than this you can use "string math" (SAdd(), SMui(), SSub() and SDiv() functions). You need to build a "remainder" function out of SDiv() and SSub() functions.
Did you ask WHY there is this requirement?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 145
- Joined: Fri May 02, 2003 9:59 am
- Location: Seattle, Washington. USA
I wrote code way back in Foxpro and Oracle to convert both ways (integer to/from binary through hexatridecimal). If I recall it was a pretty simple program.
Hmm... I wonder if I still have it somewhere.
Hmm... I wonder if I still have it somewhere.
Shawn Ramsey
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
Yep but any base conversion is merely positional. There are 0-9 i.e., 10 characters and A-Z 26 more adding to 36 and thats the base 36's significance. The name is 'hexatridecimal' meaning 6(hex) + 3(tri) * 10(decimal) = 36.chulett wrote:Simply because 'hexadecimal' is base 16 and then I did the 'tri' or 'triple' or 'times 3' part.sud wrote:why did you multiply 3 and 16 ?
Hexadecimal = 6(hex) + 10(decimal) = 16
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
Lest anyone misunderstands, Craig, one of our most valuable posters, means anal as in analytical.chulett wrote:Wow... you guys are way too anal. Did you not notice Mr Winkie? You know, as in 'wink, wink, nudge, nudge'.
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.