00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef NTG_REAL_BUILTIN_FLOAT_HH
00029 # define NTG_REAL_BUILTIN_FLOAT_HH
00030
00031 # include <ntg/config/system.hh>
00032 # include <ntg/real/behavior.hh>
00033 # include <ntg/core/internal/global_ops_traits.hh>
00034 # include <ntg/core/internal/traits.hh>
00035 # include <ntg/real/builtin_properties.hh>
00036 # include <ntg/real/optraits_real.hh>
00037 # include <ntg/core/predecls.hh>
00038
00039 # include <mlc/cmp.hh>
00040
00041 namespace ntg {
00042
00043 namespace internal {
00044
00045
00046
00047
00048
00049 template <>
00050 struct typetraits<float> : public typetraits<float_value<float> >
00051 {
00052 typedef float self;
00053 typedef decimal abstract_type;
00054 typedef self ntg_type;
00055
00056 ntg_build_value_type(float_value<E>);
00057
00058 typedef optraits<self> optraits_type;
00059 typedef unsafe::get<self> behavior_type;
00060 typedef unsafe abstract_behavior_type;
00061
00062 typedef self base_type;
00063 typedef self storage_type;
00064 typedef self signed_type;
00065 typedef self unsigned_type;
00066 typedef self cumul_type;
00067 typedef self largest_type;
00068 typedef self signed_largest_type;
00069 typedef self signed_cumul_type;
00070 typedef self unsigned_largest_type;
00071 typedef self unsigned_cumul_type;
00072 typedef self integer_type;
00073 };
00074
00075
00076
00077
00078
00079 template <>
00080 struct typetraits<double> : public typetraits<float_value<double> >
00081 {
00082 typedef double self;
00083 typedef decimal abstract_type;
00084 typedef self ntg_type;
00085
00086 ntg_build_value_type(float_value<E>);
00087
00088 typedef optraits<self> optraits_type;
00089 typedef unsafe::get<self> behavior_type;
00090 typedef unsafe abstract_behavior_type;
00091
00092 typedef self base_type;
00093 typedef self storage_type;
00094 typedef self signed_type;
00095 typedef self unsigned_type;
00096 typedef self cumul_type;
00097 typedef self largest_type;
00098 typedef self signed_largest_type;
00099 typedef self signed_cumul_type;
00100 typedef self unsigned_largest_type;
00101 typedef self unsigned_cumul_type;
00102 typedef self integer_type;
00103 };
00104
00105
00106
00107
00108
00109 template <>
00110 struct optraits<float> : public optraits<float_value<float> >
00111 {
00112 private:
00113 typedef float self;
00114 typedef typetraits<self>::storage_type storage_type_;
00115
00116 public:
00117
00118
00119
00120 static storage_type_ sup() { return NTG_FLOAT_INFINITY; }
00121 static storage_type_ inf() { return - sup (); }
00122 static std::string name() { return "float"; }
00123 };
00124
00125
00126
00127
00128
00129 struct all_float_traits
00130 {
00131 enum { commutative = true };
00132 typedef float ret;
00133 typedef float impl;
00134 };
00135
00136
00137
00138
00139
00140 template <unsigned nbits, class B>
00141 struct operator_traits<operator_plus, float, int_u<nbits, B> >
00142 : all_float_traits {};
00143
00144 template <unsigned nbits, class B>
00145 struct operator_traits<operator_plus, float, int_s<nbits, B> >
00146 : all_float_traits {};
00147
00148
00149
00150
00151 template <>
00152 struct operator_traits<operator_plus, float, float>
00153 : all_float_traits {};
00154
00155
00156
00157
00158
00159 template <unsigned nbits, class B>
00160 struct operator_traits<operator_minus, float, int_u<nbits, B> >
00161 : all_float_traits {};
00162
00163 template <unsigned nbits, class B>
00164 struct operator_traits<operator_minus, float, int_s<nbits, B> >
00165 : all_float_traits {};
00166
00167 template <>
00168 struct operator_traits<operator_minus, float, float>
00169 : all_float_traits {};
00170
00171
00172
00173
00174
00175 template <unsigned nbits, class B>
00176 struct operator_traits<operator_times, float, int_u<nbits, B> >
00177 : all_float_traits {};
00178
00179 template <unsigned nbits, class B>
00180 struct operator_traits<operator_times, float, int_s<nbits, B> >
00181 : all_float_traits {};
00182
00183 template <>
00184 struct operator_traits<operator_times, float, float>
00185 : all_float_traits {};
00186
00187
00188
00189
00190
00191 template <unsigned nbits, class B>
00192 struct operator_traits<operator_div, float, int_u<nbits, B> >
00193 : all_float_traits {};
00194
00195 template <unsigned nbits, class B>
00196 struct operator_traits<operator_div, float, int_s<nbits, B> >
00197 : all_float_traits {};
00198
00199 template <>
00200 struct operator_traits<operator_div, float, float>
00201 : all_float_traits {};
00202
00203
00204
00205
00206
00207 template <unsigned nbits, class B>
00208 struct operator_traits<operator_min, float, int_u<nbits, B> >
00209 : all_float_traits {};
00210
00211 template <unsigned nbits, class B>
00212 struct operator_traits<operator_min, float, int_s<nbits, B> >
00213 : all_float_traits {};
00214
00215 template <>
00216 struct operator_traits<operator_min, float, float>
00217 : all_float_traits {};
00218
00219
00220
00221
00222
00223 template <unsigned nbits, class B>
00224 struct operator_traits<operator_max, float, int_u<nbits, B> >
00225 : all_float_traits {};
00226
00227 template <unsigned nbits, class B>
00228 struct operator_traits<operator_max, float, int_s<nbits, B> >
00229 : all_float_traits {};
00230
00231 template <>
00232 struct operator_traits<operator_max, float, float>
00233 : all_float_traits {};
00234
00235
00236
00237
00238
00239 template <unsigned nbits, class B>
00240 struct operator_traits<operator_cmp, float, int_u<nbits, B> >
00241 : all_float_traits {};
00242
00243 template <unsigned nbits, class B>
00244 struct operator_traits<operator_cmp, float, int_s<nbits, B> >
00245 : all_float_traits {};
00246
00247 template <>
00248 struct operator_traits<operator_cmp, float, float>
00249 : all_float_traits {};
00250
00251
00252
00253
00254
00255 template <>
00256 struct optraits<double> : public optraits<float_value<double> >
00257 {
00258 private:
00259
00260 typedef double self;
00261 typedef typetraits<self>::storage_type storage_type_;
00262
00263 public:
00264
00265
00266
00267 static storage_type_ sup() { return NTG_DOUBLE_INFINITY; }
00268 static storage_type_ inf() { return - sup (); }
00269 static std::string name() { return "double"; }
00270 };
00271
00272
00273
00274
00275
00276 struct all_double_traits
00277 {
00278 enum { commutative = true };
00279 typedef double ret;
00280 typedef double impl;
00281 };
00282
00283
00284
00285
00286
00287 template <unsigned nbits, class B>
00288 struct operator_traits<operator_plus, double, int_u<nbits, B> >
00289 : all_double_traits {};
00290
00291 template <unsigned nbits, class B>
00292 struct operator_traits<operator_plus, double, int_s<nbits, B> >
00293 : all_double_traits {};
00294
00295 template <>
00296 struct operator_traits<operator_plus, double, double>
00297 : all_double_traits {};
00298
00299 template <>
00300 struct operator_traits<operator_plus, double, float>
00301 : all_double_traits {};
00302
00303
00304
00305
00306
00307 template <unsigned nbits, class B>
00308 struct operator_traits<operator_minus, double, int_u<nbits, B> >
00309 : all_double_traits {};
00310
00311 template <unsigned nbits, class B>
00312 struct operator_traits<operator_minus, double, int_s<nbits, B> >
00313 : all_double_traits {};
00314
00315 template <>
00316 struct operator_traits<operator_minus, double, double>
00317 : all_double_traits {};
00318
00319 template <>
00320 struct operator_traits<operator_minus, double, float>
00321 : all_double_traits {};
00322
00323
00324
00325
00326
00327 template <unsigned nbits, class B>
00328 struct operator_traits<operator_times, double, int_u<nbits, B> >
00329 : all_double_traits {};
00330
00331 template <unsigned nbits, class B>
00332 struct operator_traits<operator_times, double, int_s<nbits, B> >
00333 : all_double_traits {};
00334
00335 template <>
00336 struct operator_traits<operator_times, double, double>
00337 : all_double_traits {};
00338
00339 template <>
00340 struct operator_traits<operator_times, double, float>
00341 : all_double_traits {};
00342
00343
00344
00345
00346
00347 template <unsigned nbits, class B>
00348 struct operator_traits<operator_div, double, int_u<nbits, B> >
00349 : all_double_traits {};
00350
00351 template <unsigned nbits, class B>
00352 struct operator_traits<operator_div, double, int_s<nbits, B> >
00353 : all_double_traits {};
00354
00355 template <>
00356 struct operator_traits<operator_div, double, double>
00357 : all_double_traits {};
00358
00359 template <>
00360 struct operator_traits<operator_div, double, float>
00361 : all_double_traits {};
00362
00363
00364
00365
00366
00367 template <unsigned nbits, class B>
00368 struct operator_traits<operator_min, double, int_u<nbits, B> >
00369 : all_double_traits {};
00370
00371 template <unsigned nbits, class B>
00372 struct operator_traits<operator_min, double, int_s<nbits, B> >
00373 : all_double_traits {};
00374
00375 template <>
00376 struct operator_traits<operator_min, double, double>
00377 : all_double_traits {};
00378
00379 template <>
00380 struct operator_traits<operator_min, double, float>
00381 : all_double_traits {};
00382
00383
00384
00385
00386
00387 template <unsigned nbits, class B>
00388 struct operator_traits<operator_max, double, int_u<nbits, B> >
00389 : all_double_traits {};
00390
00391 template <unsigned nbits, class B>
00392 struct operator_traits<operator_max, double, int_s<nbits, B> >
00393 : all_double_traits {};
00394
00395 template <>
00396 struct operator_traits<operator_max, double, double>
00397 : all_double_traits {};
00398
00399 template <>
00400 struct operator_traits<operator_max, double, float>
00401 : all_double_traits {};
00402
00403
00404
00405
00406
00407 template <unsigned nbits, class B>
00408 struct operator_traits<operator_cmp, double, int_u<nbits, B> >
00409 : all_double_traits {};
00410
00411 template <unsigned nbits, class B>
00412 struct operator_traits<operator_cmp, double, int_s<nbits, B> >
00413 : all_double_traits {};
00414
00415 template <>
00416 struct operator_traits<operator_cmp, double, double>
00417 : all_double_traits {};
00418
00419 template <>
00420 struct operator_traits<operator_cmp, double, float>
00421 : all_double_traits {};
00422
00423 }
00424
00425 }
00426
00427 #endif // !NTG_REAL_BUILTIN_FLOAT_HH