Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ho do I convert decimal to hex with a twist?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00123780
Message ID:
00123819
Vues:
23
>>You're right about it only using integers. Hexadecimal values were used primarily for indicating the value stored in bytes, which, of course, are integers. How 'bout taking two fixed length values? Use BINTOC() to covert the integer portion, then raise the fractional portion by an appropriate power of 10 to covert that to an integer. Then use BINTOC() again and concatenate the results.
>
>Hey Geo,
>So ok this would work but one thought... ick ;)
>We're looking at N 15,4 values, so binary would be a larger expression to store. But I took your thought and came up with this to do the same kind of thing but into hex:
>
>original = 10.23
>valuestored = transform(orignal * 10000, "@0")
>originalval = val(valuestored)/10000
>
>This allows the storage of numbers with 4 decimal places like we wanted. What do you think?

If it works for you, terrific. Of course, you might be able to reduce that with:
original = 10.23
valuestored = BINTOC(original * 10000)
originalval = CTOBIN(valuestored) / 10000
This will leave you with a four character string as opposed to a ten.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform