Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary
Message
De
01/03/2006 04:20:23
 
 
À
01/03/2006 04:02:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Binary
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01100270
Message ID:
01100280
Vues:
17
>>>>Hi All,
>>>>
>>>>Is there a quick function to convert a number to binary and back again? i.e.
>>>>
>>>>
>>>>A number like
>>>>739207
>>>>convert to
>>>>10110100011110000111
>>>>convert back to
>>>>739207
>>>>
>>>>
>>>>I have manually programmed this with BITTEST() each bit in the number but was wondering if there is a simpler function / method that I'm not aware of.
>>>>
>>>>Thanks
>>>
>>>
>>>Jos,
>>>
>>>There's nothing simpler I'm aware of
>>>
>>>If it's only for occasional use, the bittest() will do fine
>>>
>>>You could speed it up by handling half a byte or one byte at a time.
>>>Then you would have an array with the value of the (half) byte + 1 as an index into the array and the value of the element would be '0000', '0001', etc
>>
>>Hi Gregory. I see. But how to easily convert the binary number back to the original number?
>
>Well, it's the other way around. Working in eg steps of 4 chars, you ascan the array for the piece (0001, 0101, ...) and the return value of ascan minus one equals the value (times 16^...)

Sorry - I meant "easily" as in a single function - lol! But thanks - I got the long way working and put into a function :)
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform