Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP And Float data type
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00258195
Message ID:
00258222
Views:
13
>Hi i am building an app using some API Calls, Everything works fine and i only have one funtion left to fix. The problem is the following:
>
>The data i receive from the Call is a 4 bytes Floating point and i really dont have a clue on how to convert the data i receive into the correct numeric value.
>
> The string i receive is Chr(174)+chr(216)+chr(255)+chr(63)+chr(0) And should convert to the numeric value 1.9988
>

That's a parameter type SINGLE, assuming that it's IEEE 754 compliant. As I remember, there's a bug related to the SINGLE parameter return value; Christof Lange and I have proven out the following code to convert a single contained in a VFP string (usually a part of a structure) back to a VFP numeric in straightforward fashion using RtlMoveMemory():
FUNCTION ConvertSINGLEToVFPNum
LPARAMETER tcSingle
* tcSingle is a 4 byte representation contained in a VFP string
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyDbl ;
	SINGLE @DestNumeric, ;
	STRING @pVoidSource, ;
	INTEGER nLength
LOCAL lnNum
lnNum = 0.000000000000000
=RtlCopyDbl(@lnNum, tcSingle, 4)
RETURN lnNum
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform