Convert floating-point from other formats to IEEE 754


Version: 2020

Type: Features

Category: Programming

Subcategory: Origin C

Jira: ORG-20431


Added following OC funtion to convert floating-point from other formats to IEEE 754.

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_IBM_SHORT,        // 32-bit
	FLOATING_POINT_TYPE_IBM_LONG,         // 64-bit
	FLOATING_POINT_TYPE_IBM_LONG_XPORT,   // 64-bit
FLOATING_POINT_TYPE_COUNT } FLOATING_POINT_TYPE;

bool convert_floating_by_format(LPVOID lpOutputBuff, LPVOID lpInputBuff, size_t nNumValues, FLOATING_POINT_TYPE nOutputFormatType, FLOATING_POINT_TYPE nInputFormatType);

For example:
void vax_test() { unsigned int a[] = {0x268bc2d9, 0x015dc2d9}; double f[2]; convert_floating_by_format(f, a, 2, FLOATING_POINT_TYPE_IEEE_DOUBLE, FLOATING_POINT_TYPE_VAX_F); // f = { -27.14381980895996, -27.12566566467285 } return; }