
GDS-806/810/820/840 Programming Manual
88
Appendix A: How can we convert the hexadecimal format to a floating point
format
Question: As the previous example listed on page 27, how can the hexadecimal
value of “0×4C 0×BE 0×BC 0×20” transfer to 100M(Sa/s)?
Answer:
just use the attached C language program:
#include <stdio.h>
int main()
{
union data
{
char a[4];
float f;
} myData;
myData.a[0]=0x20; /* little-endian byte ordering here, */
myData.a[1]=0xbc; /* so, the last of 0x20 should be placed */
myData.a[2]=0xbe; /* in the first order. */
myData.a[3]=0x4c;
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:
Comentarios a estos manuales