|
-
Aug 15th, 2001, 08:38 PM
#1
Thread Starter
New Member
Converting an 8 byte decimal to hex
Does anyone have any ideas on how to convert a 64 bit (20 digit) decimal to hex?
Problems:
The built-in Hex() function doesn't work as it only supports up to 32 bits.
I did write a custom routine to do the conversion, however it relies on setting the "maximum hex value" you want before you do the conversion. The problem here is that there aren't any data types besides a double that support a 64 bit number. And I can't use a double because I need exact accuracy in the digits and not be limited to the floating point standard. So what results is that I get the first 6 or 7 bytes of the number but not the whole thing. I'm not married to this routine, I just need anything that will convert a 20 digit decimal string to an 8 byte hex string.
Help! I have also submitted this to the general forum if this is the improper place. First post, go easy on me. Thanks
-
Aug 15th, 2001, 08:43 PM
#2
Registered User
Sure can
Take up to 29 digit integer number and converts to hex
VB Code:
Function DecToHex(ByVal x As Variant) As String
'Nucleus
Dim y%: x = CDec(x)
Do
y = (x / 16 - Int(x / 16)) * 16
If y < 10 Then DecToHex = y & DecToHex Else DecToHex = Chr$(y + 55) & DecToHex
x = Int(x / 16)
Loop While x
End Function
-
Aug 15th, 2001, 08:53 PM
#3
Thread Starter
New Member
genius.
That works perfectly. You have greatly simplified my life. Thanks
-
Aug 15th, 2001, 08:56 PM
#4
Registered User
Last edited by Nucleus; Aug 16th, 2001 at 06:51 AM.
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
|