libcommonc++  0.7
Integers.h++ File Reference
#include <commonc++/Common.h++>
#include <inttypes.h>
#include <stdint.h>
Include dependency graph for Integers.h++:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ccxx
 

Macros

#define __STDC_FORMAT_MACROS
 
#define INT64_CONST(I)   int64_t(I ## LL)
 Declare a signed 64-bit integer constant I. More...
 
#define UINT64_CONST(I)   uint64_t(I ## ULL)
 Declare an unsigned 64-bit integer constant I. More...
 
#define INT8_MIN   (-128)
 The minimum value for a signed 8-bit integer. More...
 
#define INT16_MIN   (-32767-1)
 The minimum value for a signed 16-bit integer. More...
 
#define INT32_MIN   (-2147483647-1)
 The minimum value for a signed 32-bit integer. More...
 
#define INT64_MIN   (INT64_CONST(-9223372036854775807)-1)
 The minimum value for a signed 64-bit integer. More...
 
#define INT8_MAX   (127)
 The maximum value for a signed 8-bit integer. More...
 
#define INT16_MAX   (32767)
 The maximum value for a signed 16-bit integer. More...
 
#define INT32_MAX   (2147483647)
 The maximum value for a signed 32-bit integer. More...
 
#define INT64_MAX   (INT64_CONST(9223372036854775807))
 The maximum value for a signed 64-bit integer. More...
 
#define UINT8_MAX   (255U)
 The maximum value for an unsigned 8-bit integer. More...
 
#define UINT16_MAX   (65535U)
 The maximum value for an unsigned 16-bit integer. More...
 
#define UINT32_MAX   (4294967295U)
 The maximum value for an unsigned 32-bit integer. More...
 
#define UINT64_MAX   (UINT64_CONST(18446744073709551615))
 The maximum value for an unsigned 64-bit integer. More...
 
#define INT64_FMT   "%" PRId64
 The printf() formatting directive for signed 64-bit integers. More...
 
#define UINT64_FMT   "%" PRIu64
 The printf() formatting directive for unsigned 64-bit integers. More...
 
#define INT64_P_FMT(W)   "%" #W PRId64
 The parameterized printf() formatting directive for signed 64-bit integers; W indicates the field width. More...
 
#define UINT64_P_FMT(W)   "%" #W PRIu64
 The parameterized printf() formatting directive for unsigned 64-bit integers; W indicates the field width. More...
 
#define CCXX_BIT_SET(N, BIT)   ((N) |= (1 << (BIT)))
 Set the bit at index BIT (where 0 corresponds to the LSB) in N. More...
 
#define CCXX_BIT_CLEAR(N, BIT)   (((N) &= ~(1 << (BIT))))
 Clear the bit at index BIT (where 0 corresponds to the LSB) in N. More...
 
#define CCXX_BIT_READ(N, BIT)   ((((N) & (1 << (BIT))) == 0) ? 0 : 1)
 Read the bit at index BIT (where 0 corresponds to the LSB) in N. More...
 
#define CCXX_BIT_WRITE(N, BIT, VALUE)   ((VALUE) ? CCXX_BIT_SET((N), (BIT)) : CCXX_BIT_CLEAR((N), (BIT)))
 Write the bit at index BIT (where 0 corresponds to the LSB) in N. More...
 
#define CCXX_BIT_TEST(N, BIT)   (((N) & (1 << (BIT))) != 0)
 Test the bit at index BIT (where 0 corresponds to the LSB) in N. More...
 

Typedefs

typedef unsigned char byte_t
 An unsigned 8-bit value. More...
 
typedef unsigned int uint_t
 An alias for unsigned int. More...
 
typedef int32_t time_s_t
 A time expressed in seconds since the epoch (00:00:00, UTC, January 1, 1970). More...
 
typedef int timespan_s_t
 A timespan expressed in seconds. More...
 
typedef int64_t time_ms_t
 A time expressed in milliseconds since the epoch (00:00:00, UTC, January 1, 1970). More...
 
typedef int timespan_ms_t
 A timespan expressed in milliseconds. More...
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS

◆ CCXX_BIT_CLEAR

#define CCXX_BIT_CLEAR (   N,
  BIT 
)    (((N) &= ~(1 << (BIT))))

Clear the bit at index BIT (where 0 corresponds to the LSB) in N.

The arguments are evaluated only once.

◆ CCXX_BIT_READ

#define CCXX_BIT_READ (   N,
  BIT 
)    ((((N) & (1 << (BIT))) == 0) ? 0 : 1)

Read the bit at index BIT (where 0 corresponds to the LSB) in N.

Returns 0 or 1. The arguments are evaluated only once.

◆ CCXX_BIT_SET

#define CCXX_BIT_SET (   N,
  BIT 
)    ((N) |= (1 << (BIT)))

Set the bit at index BIT (where 0 corresponds to the LSB) in N.

The arguments are evaluated only once.

◆ CCXX_BIT_TEST

#define CCXX_BIT_TEST (   N,
  BIT 
)    (((N) & (1 << (BIT))) != 0)

Test the bit at index BIT (where 0 corresponds to the LSB) in N.

Returns true if the bit is set, false otherwise. The arguments are evaluated only once.

◆ CCXX_BIT_WRITE

#define CCXX_BIT_WRITE (   N,
  BIT,
  VALUE 
)    ((VALUE) ? CCXX_BIT_SET((N), (BIT)) : CCXX_BIT_CLEAR((N), (BIT)))

Write the bit at index BIT (where 0 corresponds to the LSB) in N.

VALUE is zero (or false) to clear the bit, nonzero (or true) to set the bit. The arguments are evaluated only once.

◆ INT16_MAX

#define INT16_MAX   (32767)

The maximum value for a signed 16-bit integer.

◆ INT16_MIN

#define INT16_MIN   (-32767-1)

The minimum value for a signed 16-bit integer.

◆ INT32_MAX

#define INT32_MAX   (2147483647)

The maximum value for a signed 32-bit integer.

◆ INT32_MIN

#define INT32_MIN   (-2147483647-1)

The minimum value for a signed 32-bit integer.

◆ INT64_CONST

#define INT64_CONST (   I)    int64_t(I ## LL)

Declare a signed 64-bit integer constant I.

◆ INT64_FMT

#define INT64_FMT   "%" PRId64

The printf() formatting directive for signed 64-bit integers.

◆ INT64_MAX

#define INT64_MAX   (INT64_CONST(9223372036854775807))

The maximum value for a signed 64-bit integer.

◆ INT64_MIN

#define INT64_MIN   (INT64_CONST(-9223372036854775807)-1)

The minimum value for a signed 64-bit integer.

◆ INT64_P_FMT

#define INT64_P_FMT (   W)    "%" #W PRId64

The parameterized printf() formatting directive for signed 64-bit integers; W indicates the field width.

◆ INT8_MAX

#define INT8_MAX   (127)

The maximum value for a signed 8-bit integer.

◆ INT8_MIN

#define INT8_MIN   (-128)

The minimum value for a signed 8-bit integer.

◆ UINT16_MAX

#define UINT16_MAX   (65535U)

The maximum value for an unsigned 16-bit integer.

◆ UINT32_MAX

#define UINT32_MAX   (4294967295U)

The maximum value for an unsigned 32-bit integer.

◆ UINT64_CONST

#define UINT64_CONST (   I)    uint64_t(I ## ULL)

Declare an unsigned 64-bit integer constant I.

◆ UINT64_FMT

#define UINT64_FMT   "%" PRIu64

The printf() formatting directive for unsigned 64-bit integers.

◆ UINT64_MAX

#define UINT64_MAX   (UINT64_CONST(18446744073709551615))

The maximum value for an unsigned 64-bit integer.

◆ UINT64_P_FMT

#define UINT64_P_FMT (   W)    "%" #W PRIu64

The parameterized printf() formatting directive for unsigned 64-bit integers; W indicates the field width.

◆ UINT8_MAX

#define UINT8_MAX   (255U)

The maximum value for an unsigned 8-bit integer.