TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BIN.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _BIT(N, K)   (((N >> (3*K)) & 1) << K)
 
#define _OCT_CODED_BIN(N)
 
#define BIN11(N)   _OCT_CODED_BIN(0 ## N ## UL)
 Create a binary constant up to 11 digits long at compile time. More...
 
#define HEX__(n)   0x##n##LU
 
#define B8__(x)
 
#define BIN8(d)   ((unsigned char)B8__(HEX__(d)))
 Generate a 16-bit constant in binary notation, in 8-bit strings. More...
 
#define BIN16(dmsb, dlsb)   (((unsigned short)BIN8(dmsb) << 8) + BIN8(dlsb))
 Generate a 16-bit constant in binary notation, in 8-bit strings. More...
 
#define BIN32(dmsb, db2, db3, dlsb)
 Generate a 32-bit constant in binary notation, in 8-bit strings. More...
 

Macro Definition Documentation

#define _BIT (   N,
 
)    (((N >> (3*K)) & 1) << K)
#define _OCT_CODED_BIN (   N)
Value:
(_BIT(N, 0) | _BIT(N, 1) | _BIT(N, 2) | _BIT(N, 3) | \
_BIT(N, 4) | _BIT(N, 5) | _BIT(N, 6) | _BIT(N, 7) | \
_BIT(N, | _BIT(N, 9) | _BIT(N, 10))
#define _BIT(N, K)
Definition: BIN.h:4
#define B8__ (   x)
Value:
((x&0x0000000FLU)?1:0) \
+((x&0x000000F0LU)?2:0) \
+((x&0x00000F00LU)?4:0) \
+((x&0x0000F000LU)?8:0) \
+((x&0x000F0000LU)?16:0) \
+((x&0x00F00000LU)?32:0) \
+((x&0x0F000000LU)?64:0) \
+((x&0xF0000000LU)?128:0)
G3D::int16 x
Definition: Vector2int16.h:37
#define BIN11 (   N)    _OCT_CODED_BIN(0 ## N ## UL)

Create a binary constant up to 11 digits long at compile time.

1 int i = BIN(01100101001)

[By] Kaz Kylheku http://www.velocityreviews.com/forums/t620780-mathew-hendrys-macro-for-binary-integer-literals.html

See also
BIN8(), BIN11(), BIN16(), BIN32()
#define BIN16 (   dmsb,
  dlsb 
)    (((unsigned short)BIN8(dmsb) << 8) + BIN8(dlsb))

Generate a 16-bit constant in binary notation, in 8-bit strings.

The most significant byte is first.

1 unsigned int i = BIN16(10101010,01010101); // 43605

[Tom] Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f

See also
BIN8(), BIN11(), BIN16(), BIN32()
#define BIN32 (   dmsb,
  db2,
  db3,
  dlsb 
)
Value:
(((unsigned long)BIN8(dmsb) << 24) + \
((unsigned long)BIN8(db2) << 16) + \
((unsigned long)BIN8(db3) << 8) + \
BIN8(dlsb))
#define BIN8(d)
Generate a 16-bit constant in binary notation, in 8-bit strings.
Definition: BIN.h:56

Generate a 32-bit constant in binary notation, in 8-bit strings.

The most significant byte is first.

1 unsigned int = BIN32(10000000,11111111,10101010,01010101); // 2164238933

[Tom] Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f

See also
BIN8(), BIN11(), BIN16(), BIN32()
#define BIN8 (   d)    ((unsigned char)B8__(HEX__(d)))

Generate a 16-bit constant in binary notation, in 8-bit strings.

The most significant byte is first.

1 unsigned int i = BIN8(01010101); // 85

[Tom] Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f

See also
BIN8(), BIN11(), BIN16(), BIN32()
#define HEX__ (   n)    0x##n##LU