convert_floating_by_format
Description
Convert floating point by format.
Syntax
bool convert_floating_by_format( LPVOID lpOutputBuff, LPVOID lpInputBuff, size_t nNumValues, FLOATING_POINT_TYPE nOutputFormatType, FLOATING_POINT_TYPE nInputFormatType )
Parameters
- lpOutputBuff
- [output] A pointer to the buffer that receives the convert value
- lpInputBuff
- [input] A pointer to the buffer containing the data to convert
- nNumValues
- [input] number of floating points
- nOutputFormatType
- [input] output format type. See FLOATING_POINT_TYPE
- nInputFormatType
- [input] input format type. See FLOATING_POINT_TYPE
typedef enum
{
FLOATING_POINT_TYPE_IEEE_FLOAT = 0, // 32-bit
FLOATING_POINT_TYPE_IEEE_DOUBLE, // 64-bit
FLOATING_POINT_TYPE_VAX_F, // 32-bit, ~[-2.9E-39, 1.7E+38]
FLOATING_POINT_TYPE_VAX_D, // 64-bit, ~[-2.9E-39, 1.7E+38]
FLOATING_POINT_TYPE_VAX_G, // 64-bit, ~[-5.6E-309, 0.9E+308]
// FLOATING_POINT_TYPE_VAX_H, // 128-bit, NOT supported
FLOATING_POINT_TYPE_IBM_SHORT, // 32-bit
FLOATING_POINT_TYPE_IBM_LONG, // 64-bit
FLOATING_POINT_TYPE_IBM_LONG_XPORT, // 64-bit
} FLOATING_POINT_TYPE;
Return
true on success and false on failure.
Examples
EX1
void convert_floating_by_format_vax()
{
unsigned int a[] = {0x268bc2d9, 0x015dc2d9};
double f1[2];
bool bRet = convert_floating_by_format(f1, a, 2, FLOATING_POINT_TYPE_IEEE_DOUBLE, FLOATING_POINT_TYPE_VAX_F);
printf("f1[0]=%f\n", f1[0]);
printf("f1[1]=%f\n", f1[1]);
return;
}
Remark
See Also
header to Include
origin.h
Reference
|