|
-
Oct 6th, 2007, 11:18 AM
#1
Thread Starter
Addicted Member
Converting Dec Numbers
I sometimes use the Hex$ function to convert a large Dec number to a Hex string in VB6. This works great to a point. If a Dec number is greater than 2147483647 the Hex$ function returns an overflow error. This is due to the Hex$ function only going to 8 places and 2147483647 = 7FFFFFFF.
If a larger number needs to be converted it will probably require writing a routine to do this for me. I do not think there is any mathematical formula that will do this for me.
Any ideas?
-
Oct 6th, 2007, 11:26 AM
#2
Junior Member
Re: Converting Dec Numbers
in assembler you could shift the value 16 times to the right and they you had the upper 16 bit as seperate value.
so actually what you do is a hex division by 65535
so your value will be something like
x=hex(value shr 16) & right("00000000"&hex(value and &hFFFFFFFF),8)
probably not the correct syntax but I guess you get the idea
-
Oct 6th, 2007, 11:58 AM
#3
Thread Starter
Addicted Member
Re: Converting Dec Numbers
In assembly langue all numbers are dtored as hex in memory locations anyway. It is the actual conversion to hex I am trying to replicate.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|