Convert HEX value to a LONG value in Coldfusion

Hello,

There are several functions out there to convert HEX values to decimals, strings and floats(thanks again @_agx_) and can be found here:

http://www.cflib.org/udf/HexToDec
http://www.cflib.org/udf/hexToString
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_25617810.html

What I need to do is convert the HEX value to a LONG Value.

Thank you very much in advance!!!!!!!!!!!!!!!!!!!!!!!!!
stracqanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
Sorry, I missed your last post.  I don't know of any existing udf's for this one.  Assuming you have createObject() access, I'd use java.  I'd also convert it to a date object.  So you can format it however you want.

<cfset str = "(the hex value...)">
<cfset l = createObject("java", "java.lang.Long").parseLong( str, 16 )>
<cfset valueAsDate = createObject("java", "java.util.Date").init( l )>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jones911Commented:
Well Hex is Base16, Decimal is Base 10 so:

Example 5a in Hex is 90 in decimal:

#InputBaseN("5a",16)#

Will output 90.
0
_agx_Commented:
@Jones911  

Unfortunately, it's not as simple as that.  I wish it were ;-) I've been working with the asker on another thread with specific test data, and the conversions just do not work out right.  Plus, CF has some issues with the Long type.  Numbers get truncated or bomb entirely once you go above Integer.MAXIMUM_VALUE (which their values routinely do ..)   So the java route is safer all around here.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

stracqanAuthor Commented:
WORKED ABOSULTELY PERFECT AGAIN!!!!!!!! In like an hour I should be finished with my algo :-)

Thank you so very much!!!
0
stracqanAuthor Commented:
Again, SUBERB!!!!!! Thank you  very much for all of your  help!!!
0
_agx_Commented:
Awesome.  BTW: It was an interesting api, so I created an algorithm too .. just for fun. If you want to compare notes, feel free to email me (address is in my profile).  I'm curious if mine works properly on real data ;-), but no pressure either way.  I'm just glad I could help. Cheers.
0
stracqanAuthor Commented:
Sent!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.