beautypg.com

GW Instek GDS-2000 series Programming manual User Manual

Page 93

background image

GDS-2000 Series Programming Manual

93

Appendix A: How can we convert the hexadecimal format to a floating point

format

Question: As the previous example listed on page 32, how can the hexadecimal

value of “0Ч34 0Ч56 0ЧBF 0Ч94” transfer to 200ns?

Answer:

just use the attached C language program:

#include
int main()
{
union data
{
char a[4];
float f;
} myData;
myData.a[0]=0x94; /* little-endian byte ordering here, */
myData.a[1]=0xBF; /* so, the last of 0x94 should be placed */
myData.a[2]=0x56; /* in the first order. */
myData.a[3]=0x34;
printf("Here is the Data:\n%0x\n%0x\n%0x\n%0x\n%.3e\n",\
myData.a[0]&0xff,

myData.a[1]&0xff,
myData.a[2]&0xff,
myData.a[3]&0xff,\

myData.f );
return 0;
}

and the output result is following: 2.000e -007=200ns