float16 converter is explicitly declared non-compatible with non-IEEE754

This commit is contained in:
Pavel Kirienko 2015-08-21 14:50:29 +03:00
parent ec1210dfec
commit 9c185b3ddf
2 changed files with 8 additions and 7 deletions

View File

@ -36,9 +36,10 @@ struct NativeFloatSelector
class UAVCAN_EXPORT IEEE754Converter
{
// TODO: Non-IEEE float support for float32 and float64
static uint16_t nativeNonIeeeToHalf(float value);
static float halfToNativeNonIeee(uint16_t value);
// TODO: Non-IEEE float support
static uint16_t nativeIeeeToHalf(float value);
static float halfToNativeIeee(uint16_t value);
IEEE754Converter();
@ -80,13 +81,13 @@ template <>
inline typename IntegerSpec<16, SignednessUnsigned, CastModeTruncate>::StorageType
IEEE754Converter::toIeee<16>(typename NativeFloatSelector<16>::Type value)
{
return nativeNonIeeeToHalf(value);
return nativeIeeeToHalf(value);
}
template <>
inline typename NativeFloatSelector<16>::Type
IEEE754Converter::toNative<16>(typename IntegerSpec<16, SignednessUnsigned, CastModeTruncate>::StorageType value)
{
return halfToNativeNonIeee(value);
return halfToNativeIeee(value);
}

View File

@ -11,7 +11,7 @@ namespace uavcan
/*
* IEEE754Converter
*/
uint16_t IEEE754Converter::nativeNonIeeeToHalf(float value)
uint16_t IEEE754Converter::nativeIeeeToHalf(float value)
{
/*
* https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/halffloat.c
@ -103,7 +103,7 @@ uint16_t IEEE754Converter::nativeNonIeeeToHalf(float value)
return uint16_t(h_sgn + h_exp + h_sig);
}
float IEEE754Converter::halfToNativeNonIeee(uint16_t value)
float IEEE754Converter::halfToNativeIeee(uint16_t value)
{
/*
* https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/halffloat.c