mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
float16 converter is explicitly declared non-compatible with non-IEEE754
This commit is contained in:
parent
ec1210dfec
commit
9c185b3ddf
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user