1 #ifndef __NUMERICINFO_H_ 2 #define __NUMERICINFO_H_ 43 # include <sys/types.h> 66 template <
class NUMBER>
70 inline bool signed_type()
const;
72 inline bool integer_type()
const;
74 inline size_t size_in_bytes()
const;
75 inline size_t size_in_bits()
const;
77 inline NUMBER max_value()
const;
78 inline NUMBER min_value()
const;
80 inline NumericType type_id()
const;
89 typedef signed char type;
92 bool signed_type()
const {
return true; }
93 bool integer_type()
const {
return true; }
94 size_t size_in_bytes()
const {
return sizeof(type); }
95 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
96 type max_value()
const {
return SCHAR_MAX; }
97 type min_value()
const {
return SCHAR_MIN; }
98 NumericType type_id()
const {
return NumericType::SCHAR; }
105 typedef unsigned char type;
108 bool signed_type()
const {
return false; }
109 bool integer_type()
const {
return true; }
110 size_t size_in_bytes()
const {
return sizeof(type); }
111 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
112 type max_value()
const {
return UCHAR_MAX; }
113 type min_value()
const {
return 0; }
114 NumericType type_id()
const {
return NumericType::UCHAR; }
121 typedef signed short type;
124 bool signed_type()
const {
return true; }
125 bool integer_type()
const {
return true; }
126 size_t size_in_bytes()
const {
return sizeof(type); }
127 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
128 type max_value()
const {
return SHRT_MAX; }
129 type min_value()
const {
return SHRT_MIN; }
130 NumericType type_id()
const {
return NumericType::SHORT; }
137 typedef unsigned short type;
140 bool signed_type()
const {
return false; }
141 bool integer_type()
const {
return true; }
142 size_t size_in_bytes()
const {
return sizeof(type); }
143 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
144 type max_value()
const {
return USHRT_MAX; }
145 type min_value()
const {
return 0; }
146 NumericType type_id()
const {
return NumericType::USHORT; }
153 typedef signed int type;
156 bool signed_type()
const {
return true; }
157 bool integer_type()
const {
return true; }
158 size_t size_in_bytes()
const {
return sizeof(type); }
159 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
160 type max_value()
const {
return INT_MAX; }
161 type min_value()
const {
return INT_MIN; }
162 NumericType type_id()
const {
return NumericType::INT; }
169 typedef unsigned int type;
172 bool signed_type()
const {
return false; }
173 bool integer_type()
const {
return true; }
174 size_t size_in_bytes()
const {
return sizeof(type); }
175 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
176 type max_value()
const {
return UINT_MAX; }
177 type min_value()
const {
return 0; }
178 NumericType type_id()
const {
return NumericType::UINT; }
185 typedef signed long type;
188 bool signed_type()
const {
return true; }
189 bool integer_type()
const {
return true; }
190 size_t size_in_bytes()
const {
return sizeof(type); }
191 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
192 type max_value()
const {
return LONG_MAX; }
193 type min_value()
const {
return LONG_MIN; }
194 NumericType type_id()
const {
return NumericType::LONG; }
201 typedef unsigned long type;
204 bool signed_type()
const {
return false; }
205 bool integer_type()
const {
return true; }
206 size_t size_in_bytes()
const {
return sizeof(type); }
207 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
208 type max_value()
const {
return ULONG_MAX; }
209 type min_value()
const {
return 0; }
210 NumericType type_id()
const {
return NumericType::ULONG; }
220 bool signed_type()
const {
return true; }
221 bool integer_type()
const {
return false; }
222 size_t size_in_bytes()
const {
return sizeof(type); }
223 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
224 type max_value()
const {
return FLT_MAX; }
225 type min_value()
const {
return -FLT_MAX; }
226 NumericType type_id()
const {
return NumericType::FLOAT; }
236 bool signed_type()
const {
return true; }
237 bool integer_type()
const {
return false; }
238 size_t size_in_bytes()
const {
return sizeof(type); }
239 size_t size_in_bits() {
return CHAR_BIT * size_in_bytes(); }
240 type max_value()
const {
return DBL_MAX; }
241 type min_value()
const {
return -DBL_MAX; }
242 NumericType type_id()
const {
return NumericType::DOUBLE; }
class NumericInfo<NUMBER> defines properties for the type NUMBER.
Definition: convert_array.h:33
provides names for some numeric types and methods for finding their properties.
Definition: NumericType.h:54
This file declares the stir::NumericType class.