Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert hexa to decimal
Message
From
13/06/2008 10:22:26
 
 
To
12/06/2008 07:19:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01323395
Message ID:
01323819
Views:
15
This message has been marked as the solution to the initial question of the thread.
Hi Pavel,

What's about:
sNum= "84028A8918BE04"
sRes= ""
DO WHILE !EMPTY(sNum)
	sRes= STR(LongDiv(@sNum, 16, 10),1)+sRes
ENDDO
?sRes

*-------------------------------
FUNCTION LongDiv(sNum, nBase, nDiv)
* Devides sNum (a number as string) with base nBase by nDiv.
* Returns the remainder and puts the quotient in sNum.

* Sergey Karimov

LOCAL i, s, nQuot, sQuot, nMod

sQuot= ""
nMod= 0
FOR i=1 TO LEN(sNum)
	s= SUBSTR(sNum,i,1)
	nMod= nMod*nBase + ASC(s) - IIF(s<="9", ASC("0"), ASC("A")-10)
	nQuot= INT(nMod/nDiv)
	sQuot= sQuot+IIF(nQuot=0 .and. EMPTY(sQuot), "", CHR(nQuot+IIF(nQuot<=9,ASC("0"),ASC("A")-10)))
	nMod= nMod%nDiv
ENDFOR

sNum= sQuot

RETURN nMod
>Hi,
>I want to convert hexa 0x84028A8918BE04 into varchar datatype "37157490954649092",
>evaluate("0x84028A8918BE04") returns 37157490954649090 (precision more than 16 digits),
>can it be done in vfp another way?
>Pavel Poul
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform