Support Forum       G3D Web Page     
Macros
BIN.h File Reference

G3D Innovation Engine http://casual-effects.com/g3d Copyright 2000-2019, Morgan McGuire All rights reserved Available under the BSD License. More...

Macros

#define _BIT(N, K)   (((N >> (3*K)) & 1) << K)
 
#define _OCT_CODED_BIN(N)
 
#define B8__(x)
 
#define BIN11(N)   _OCT_CODED_BIN(0 ## N ## UL)
 Create a binary constant up to 11 digits long at compile time. 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...
 
#define BIN8(d)   ((unsigned char)B8__(HEX__(d)))
 Generate a 16-bit constant in binary notation, in 8-bit strings. More...
 
#define HEX__(n)   0x##n##LU
 

Detailed Description

G3D Innovation Engine http://casual-effects.com/g3d Copyright 2000-2019, Morgan McGuire All rights reserved Available under the BSD License.

Macro Definition Documentation

◆ _BIT

#define _BIT (   N,
 
)    (((N >> (3*K)) & 1) << K)

◆ _OCT_CODED_BIN

#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:12

◆ B8__

#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)

◆ BIN11

#define BIN11 (   N)    _OCT_CODED_BIN(0 ## N ## UL)

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

int i = BIN(01100101001)
Referenced Code: By Kaz Kylheku http://www.velocityreviews.com/forums/t620780-mathew-hendrys-macro-for-binary-integer-literals.html
See also
BIN8(), BIN11(), BIN16(), BIN32()

◆ BIN16

#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.

unsigned int i = BIN16(10101010,01010101); // 43605
Referenced Code: Tom Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f
See also
BIN8(), BIN11(), BIN16(), BIN32()

◆ 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:64

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

The most significant byte is first.

unsigned int = BIN32(10000000,11111111,10101010,01010101); // 2164238933
Referenced Code: Tom Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f
See also
BIN8(), BIN11(), BIN16(), BIN32()

◆ BIN8

#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.

unsigned int i = BIN8(01010101); // 85
Referenced Code: Tom Torfs http://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f
See also
BIN8(), BIN11(), BIN16(), BIN32()

◆ HEX__

#define HEX__ (   n)    0x##n##LU

documentation generated on Wed Nov 24 2021 08:01:50 using doxygen 1.8.15