Wiselib
|
#include <floating_point.h>
Public Types | |
typedef OsModel_P | OsModel |
typedef BlockData_P | BlockData |
typedef double | Type |
typedef OsModel::size_t | size_t |
Static Public Member Functions | |
static size_t | write (BlockData *target, Type &value) |
When a 4-byte double value is written, it is automatically transformed into an 8-byte one (as expected when dealing with double-precision floating points). | |
static Type | read (BlockData *target) |
When a 4-byte double value is written, it is automatically transformed into an 8-byte one (as expected when dealing with double-precision floating points). | |
Static Public Attributes | |
static const int | Size = 4 |
typedef BlockData_P wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::BlockData |
typedef OsModel_P wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::OsModel |
typedef OsModel::size_t wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::size_t |
typedef double wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::Type |
static Type wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::read | ( | BlockData * | target | ) | [inline, static] |
When a 4-byte double value is written, it is automatically transformed into an 8-byte one (as expected when dealing with double-precision floating points).
Therefore, +------+------+------+------+------+------+------+------+ |byte 0|byte 1|byte 2|byte 3|byte 4|byte 5|byte 6|byte 7| S| E | F | +------+------+------+------+------+------+------+------+ 1|<--11-->|<-----------------52 bits------------------->| <-----------------------64 bits-------------------------> DOUBLE-PRECISION FLOATING-POINT must be shrunk to +-------+-------+-------+-------+ |byte 0 |byte 1 |byte 2 |byte 3 | SINGLE-PRECISION S| E | F | FLOATING-POINT NUMBER +-------+-------+-------+-------+ 1|<- 8 ->|<-------23 bits------>| <------------32 bits------------>
This works as follows:
However, since source F starts at bit 9, it requires a lot bit shifting, especially because of the additional transformation from little to big endian :(
static size_t wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::write | ( | BlockData * | target, |
Type & | value | ||
) | [inline, static] |
When a 4-byte double value is written, it is automatically transformed into an 8-byte one (as expected when dealing with double-precision floating points).
Therefore, +-------+-------+-------+-------+ |byte 0 |byte 1 |byte 2 |byte 3 | SINGLE-PRECISION S| E | F | FLOATING-POINT NUMBER +-------+-------+-------+-------+ 1|<- 8 ->|<-------23 bits------>| <------------32 bits------------> must be expanded to +------+------+------+------+------+------+------+------+ |byte 0|byte 1|byte 2|byte 3|byte 4|byte 5|byte 6|byte 7| S| E | F | +------+------+------+------+------+------+------+------+ 1|<--11-->|<-----------------52 bits------------------->| <-----------------------64 bits-------------------------> DOUBLE-PRECISION FLOATING-POINT
This works as follows:
However, since source F starts at bit 9, it requires a lot bit shifting, especially because of the additional transformation from little to big endian :(
const int wiselib::FpSerialization< OsModel_P, WISELIB_LITTLE_ENDIAN, BlockData_P, double, 4 >::Size = 4 [static] |