Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added signed integer variants of the existing unsigned functions
  • Loading branch information
Bill-Gray committed May 1, 2018
1 parent 9d61da3 commit 5f2ca7e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions get_bin.h
Expand Up @@ -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)\
Expand All @@ -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;
Expand Down

0 comments on commit 5f2ca7e

Please sign in to comment.