Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary (base 2) - Decimal Conversion
Message
 
To
06/07/1998 09:21:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00114476
Message ID:
00114564
Views:
14
>>Before I implement my own conversion functions, anyone know of any built in FP functions for going from binary to decimal and back?
>
>why do you need that Bruce ?
>in VFP you can do binary (bit-wise) operations directly on decimals
>all the BIT functions (BITTEST,BITOR,BITLSHIFT etc.)
>
>Arnon

Unless I misunderstand Bruce's question, the bitwise functions won't help him here. His reference to "decimal" leads me to think that his problem deals with floating point numbers. The bitwise functions only work on the integer portion of the number. For example, if lnvalue = 4.02, BITLSHIFT(lnvalue, 0) returns 4. Further, BITTEST() is limited to testing bits 0 through 31. I'm not 100% sure, but I believe VFP stores its floating points as at least 8 byte, double percision numbers.

However, if he can raise these decimal values to an appropriate factor of 10 to capture the necessary decimal portion, then BINTOC() and CTOBIN() might, in conjunction with these, be of use. I say this because BINTOC() returns the value in most to least significant bytes (as opposed to the normal lsb to msb format) and the most significant bit is set for positive numbers and cleared for negatives, rather than the other way around, which is the normal storage method.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform