FixMath
IntegerType.h
1 #ifndef INTTYPE_H_
2 #define INTTYPE_H_
3 
4 #include <Arduino.h>
5 
9 template<uint8_t BYTES> struct IntegerType {
10  // at an odd value, such as 3 bytes? Add one more byte (up to at most 8 bytes)..
11  typedef typename IntegerType<(BYTES < 8) ? (BYTES+1) : 8>::unsigned_type unsigned_type;
12  typedef typename IntegerType<(BYTES < 8) ? (BYTES+1) : 8>::signed_type signed_type;
13 };
14 
15 // These are the specializations for the types that we actually assume to exist:
16 template<> struct IntegerType<1> {
17  typedef uint8_t unsigned_type;
18  typedef int8_t signed_type;
19 };
20 
21 template<> struct IntegerType<2> {
22  typedef uint16_t unsigned_type;
23  typedef int16_t signed_type;
24 };
25 
26 template<> struct IntegerType<4> {
27  typedef uint32_t unsigned_type;
28  typedef int32_t signed_type;
29 };
30 
31 template<> struct IntegerType<8> {
32  typedef uint64_t unsigned_type;
33  typedef int64_t signed_type;
34 };
35 
36 #endif /* INTTYPE_H_ */
Definition: IntegerType.h:9