diff --git a/get_bin.h b/get_bin.h index 6f71337..d1977a5 100644 --- a/get_bin.h +++ b/get_bin.h @@ -52,6 +52,11 @@ is defined can be modified. */ #define get16bits(d) (*((const uint16_t *) (d))) #define get32bits(d) (*((const uint32_t *) (d))) #define get64bits(d) (*((const uint64_t *) (d))) + +/* Signed integer extraction : */ + #define get16sbits(d) (*((const int16_t *) (d))) + #define get32sbits(d) (*((const int32_t *) (d))) + #define get64sbits(d) (*((const int64_t *) (d))) #define get_double(d) (*((const double *) (d))) #else /* Can't directly read binary data */ #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ @@ -61,6 +66,10 @@ is defined can be modified. */ +(((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ +(uint32_t)(((const uint8_t *)(d))[0]) ) + #define get16sbits(d) ((int16_t)( get16bits( d))) + #define get32sbits(d) ((int32_t)( get32bits( d))) + #define get64sbits(d) ((int64_t)( get64bits( d))) + static inline double get_double( const void *iptr) { const char *idata = (const char *)iptr;