Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decimal to hexadecimal
Message
From
09/08/2000 12:42:51
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00402852
Message ID:
00402864
Views:
8
PROCEDURE dec2hex(nDecimal,nDigits)
* Returns Hex notation in a string whose length
* is always at least 2.  The nDigits parameter can be specified to pad the
* string with zeroes.

IF PARAMETERS() = 2
   RETURN RIGHT(TRANSFORM(nDecimal, "@0"), IIF(nDigits <= 8, nDigits, 8))
ENDIF

*  If no second parameter, must determine correct number of digits.
nExponent = 2	&& Always return at least two characters.
DO WHILE nExponent < 9
   IF nDecimal <= (16^nExponent)
      RETURN RIGHT(TRANSFORM(nDecimal, "@0"), nExponent)
   ENDIF
   nExponent = nExponent + 1
ENDDO
ENDPROC
>Yes it is cool. But I am looking for dec. to Hex. :(
>>Wait a sec...this is kinda cool:
>>
>>?EVALUATE("0xF")
>>15
>>?EVALUATE("0xFF")
>>255
>>
>>So I guess EVAL() converts hex to decimal.....
>>
>>>Not directly, but look at the Hex2Dec and Dec2Hex Formset methods in the HexEdit application (HexEdit.SCX) which is in the HOME()+"\tools\hexedit" directory.
>>>
>>>>Does VFP have function to convert Decimals values to Hexadecimals values?
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Reply
Map
View

Click here to load this message in the networking platform