00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_checked_int_inlines_hh
00025 #define PPL_checked_int_inlines_hh 1
00026
00027 #include "C_Integer.hh"
00028 #include <cerrno>
00029 #include <cstdlib>
00030 #include <climits>
00031 #include <string>
00032
00033 #if !PPL_HAVE_DECL_STRTOLL
00034 signed long long
00035 strtoll(const char* nptr, char** endptr, int base);
00036 #endif
00037
00038 #if !PPL_HAVE_DECL_STRTOULL
00039 unsigned long long
00040 strtoull(const char* nptr, char** endptr, int base);
00041 #endif
00042
00043 namespace Parma_Polyhedra_Library {
00044
00045 namespace Checked {
00046
00047 #ifndef PPL_HAVE_INT_FAST16_T
00048 typedef int16_t int_fast16_t;
00049 #endif
00050
00051 #ifndef PPL_HAVE_INT_FAST32_T
00052 typedef int32_t int_fast32_t;
00053 #endif
00054
00055 #ifndef PPL_HAVE_INT_FAST64_T
00056 typedef int64_t int_fast64_t;
00057 #endif
00058
00059 #ifndef PPL_HAVE_UINT_FAST16_T
00060 typedef uint16_t uint_fast16_t;
00061 #endif
00062
00063 #ifndef PPL_HAVE_UINT_FAST32_T
00064 typedef uint32_t uint_fast32_t;
00065 #endif
00066
00067 #ifndef PPL_HAVE_UINT_FAST64_T
00068 typedef uint64_t uint_fast64_t;
00069 #endif
00070
00071 template <typename Policy, typename Type>
00072 struct Extended_Int {
00073 static const Type plus_infinity = C_Integer<Type>::max;
00074 static const Type minus_infinity = (C_Integer<Type>::min >= 0
00075 ? C_Integer<Type>::max - 1
00076 : C_Integer<Type>::min);
00077 static const Type not_a_number = (C_Integer<Type>::min >= 0
00078 ? C_Integer<Type>::max - Policy::has_infinity * 2
00079 : C_Integer<Type>::min + Policy::has_infinity);
00080 static const Type min = (C_Integer<Type>::min
00081 + (C_Integer<Type>::min >= 0 ? 0
00082 : (Policy::has_infinity + Policy::has_nan)));
00083 static const Type max = (C_Integer<Type>::max
00084 - (C_Integer<Type>::min >= 0
00085 ? (2 * Policy::has_infinity + Policy::has_nan)
00086 : Policy::has_infinity));
00087 };
00088
00089 template <typename Policy, typename To>
00090 inline Result
00091 set_neg_overflow_int(To& to, Rounding_Dir dir) {
00092 if (round_up(dir)) {
00093 to = Extended_Int<Policy, To>::min;
00094 return V_LT_INF;
00095 }
00096 else {
00097 if (Policy::has_infinity) {
00098 to = Extended_Int<Policy, To>::minus_infinity;
00099 return V_GT_MINUS_INFINITY;
00100 }
00101 return V_GT_MINUS_INFINITY | V_UNREPRESENTABLE;
00102 }
00103 }
00104
00105 template <typename Policy, typename To>
00106 inline Result
00107 set_pos_overflow_int(To& to, Rounding_Dir dir) {
00108 if (round_down(dir)) {
00109 to = Extended_Int<Policy, To>::max;
00110 return V_GT_SUP;
00111 }
00112 else {
00113 if (Policy::has_infinity) {
00114 to = Extended_Int<Policy, To>::plus_infinity;
00115 return V_LT_PLUS_INFINITY;
00116 }
00117 return V_LT_PLUS_INFINITY | V_UNREPRESENTABLE;
00118 }
00119 }
00120
00121 template <typename Policy, typename To>
00122 inline Result
00123 round_lt_int_no_overflow(To& to, Rounding_Dir dir) {
00124 if (round_down(dir)) {
00125 --to;
00126 return V_GT;
00127 }
00128 return V_LT;
00129 }
00130
00131 template <typename Policy, typename To>
00132 inline Result
00133 round_gt_int_no_overflow(To& to, Rounding_Dir dir) {
00134 if (round_up(dir)) {
00135 ++to;
00136 return V_LT;
00137 }
00138 return V_GT;
00139 }
00140
00141 template <typename Policy, typename To>
00142 inline Result
00143 round_lt_int(To& to, Rounding_Dir dir) {
00144 if (round_down(dir)) {
00145 if (to == Extended_Int<Policy, To>::min) {
00146 if (Policy::has_infinity) {
00147 to = Extended_Int<Policy, To>::minus_infinity;
00148 return V_GT_MINUS_INFINITY;
00149 }
00150 return V_GT_MINUS_INFINITY | V_UNREPRESENTABLE;
00151 }
00152 else {
00153 --to;
00154 return V_GT;
00155 }
00156 }
00157 return V_LT;
00158 }
00159
00160 template <typename Policy, typename To>
00161 inline Result
00162 round_gt_int(To& to, Rounding_Dir dir) {
00163 if (round_up(dir)) {
00164 if (to == Extended_Int<Policy, To>::max) {
00165 if (Policy::has_infinity) {
00166 to = Extended_Int<Policy, To>::plus_infinity;
00167 return V_LT_PLUS_INFINITY;
00168 }
00169 return V_LT_PLUS_INFINITY | V_UNREPRESENTABLE;
00170 }
00171 else {
00172 ++to;
00173 return V_LT;
00174 }
00175 }
00176 return V_GT;
00177 }
00178
00179 PPL_SPECIALIZE_COPY(copy_generic, char)
00180 PPL_SPECIALIZE_COPY(copy_generic, signed char)
00181 PPL_SPECIALIZE_COPY(copy_generic, signed short)
00182 PPL_SPECIALIZE_COPY(copy_generic, signed int)
00183 PPL_SPECIALIZE_COPY(copy_generic, signed long)
00184 PPL_SPECIALIZE_COPY(copy_generic, signed long long)
00185 PPL_SPECIALIZE_COPY(copy_generic, unsigned char)
00186 PPL_SPECIALIZE_COPY(copy_generic, unsigned short)
00187 PPL_SPECIALIZE_COPY(copy_generic, unsigned int)
00188 PPL_SPECIALIZE_COPY(copy_generic, unsigned long)
00189 PPL_SPECIALIZE_COPY(copy_generic, unsigned long long)
00190
00191 template <typename Policy, typename Type>
00192 inline Result
00193 classify_int(const Type v, bool nan, bool inf, bool sign) {
00194 if (Policy::has_nan
00195 && (nan || sign)
00196 && v == Extended_Int<Policy, Type>::not_a_number)
00197 return V_NAN;
00198 if (!inf && !sign)
00199 return V_LGE;
00200 if (Policy::has_infinity) {
00201 if (v == Extended_Int<Policy, Type>::minus_infinity)
00202 return inf ? V_EQ_MINUS_INFINITY : V_LT;
00203 if (v == Extended_Int<Policy, Type>::plus_infinity)
00204 return inf ? V_EQ_PLUS_INFINITY : V_GT;
00205 }
00206 if (sign) {
00207 if (v < 0)
00208 return V_LT;
00209 if (v > 0)
00210 return V_GT;
00211 return V_EQ;
00212 }
00213 return V_LGE;
00214 }
00215
00216 PPL_SPECIALIZE_CLASSIFY(classify_int, char)
00217 PPL_SPECIALIZE_CLASSIFY(classify_int, signed char)
00218 PPL_SPECIALIZE_CLASSIFY(classify_int, signed short)
00219 PPL_SPECIALIZE_CLASSIFY(classify_int, signed int)
00220 PPL_SPECIALIZE_CLASSIFY(classify_int, signed long)
00221 PPL_SPECIALIZE_CLASSIFY(classify_int, signed long long)
00222 PPL_SPECIALIZE_CLASSIFY(classify_int, unsigned char)
00223 PPL_SPECIALIZE_CLASSIFY(classify_int, unsigned short)
00224 PPL_SPECIALIZE_CLASSIFY(classify_int, unsigned int)
00225 PPL_SPECIALIZE_CLASSIFY(classify_int, unsigned long)
00226 PPL_SPECIALIZE_CLASSIFY(classify_int, unsigned long long)
00227
00228 template <typename Policy, typename Type>
00229 inline bool
00230 is_nan_int(const Type v) {
00231 return Policy::has_nan && v == Extended_Int<Policy, Type>::not_a_number;
00232 }
00233
00234 PPL_SPECIALIZE_IS_NAN(is_nan_int, char)
00235 PPL_SPECIALIZE_IS_NAN(is_nan_int, signed char)
00236 PPL_SPECIALIZE_IS_NAN(is_nan_int, signed short)
00237 PPL_SPECIALIZE_IS_NAN(is_nan_int, signed int)
00238 PPL_SPECIALIZE_IS_NAN(is_nan_int, signed long)
00239 PPL_SPECIALIZE_IS_NAN(is_nan_int, signed long long)
00240 PPL_SPECIALIZE_IS_NAN(is_nan_int, unsigned char)
00241 PPL_SPECIALIZE_IS_NAN(is_nan_int, unsigned short)
00242 PPL_SPECIALIZE_IS_NAN(is_nan_int, unsigned int)
00243 PPL_SPECIALIZE_IS_NAN(is_nan_int, unsigned long)
00244 PPL_SPECIALIZE_IS_NAN(is_nan_int, unsigned long long)
00245
00246 template <typename Policy, typename Type>
00247 inline bool
00248 is_minf_int(const Type v) {
00249 return Policy::has_infinity
00250 && v == Extended_Int<Policy, Type>::minus_infinity;
00251 }
00252
00253 PPL_SPECIALIZE_IS_MINF(is_minf_int, char)
00254 PPL_SPECIALIZE_IS_MINF(is_minf_int, signed char)
00255 PPL_SPECIALIZE_IS_MINF(is_minf_int, signed short)
00256 PPL_SPECIALIZE_IS_MINF(is_minf_int, signed int)
00257 PPL_SPECIALIZE_IS_MINF(is_minf_int, signed long)
00258 PPL_SPECIALIZE_IS_MINF(is_minf_int, signed long long)
00259 PPL_SPECIALIZE_IS_MINF(is_minf_int, unsigned char)
00260 PPL_SPECIALIZE_IS_MINF(is_minf_int, unsigned short)
00261 PPL_SPECIALIZE_IS_MINF(is_minf_int, unsigned int)
00262 PPL_SPECIALIZE_IS_MINF(is_minf_int, unsigned long)
00263 PPL_SPECIALIZE_IS_MINF(is_minf_int, unsigned long long)
00264
00265 template <typename Policy, typename Type>
00266 inline bool
00267 is_pinf_int(const Type v) {
00268 return Policy::has_infinity
00269 && v == Extended_Int<Policy, Type>::plus_infinity;
00270 }
00271
00272 PPL_SPECIALIZE_IS_PINF(is_pinf_int, char)
00273 PPL_SPECIALIZE_IS_PINF(is_pinf_int, signed char)
00274 PPL_SPECIALIZE_IS_PINF(is_pinf_int, signed short)
00275 PPL_SPECIALIZE_IS_PINF(is_pinf_int, signed int)
00276 PPL_SPECIALIZE_IS_PINF(is_pinf_int, signed long)
00277 PPL_SPECIALIZE_IS_PINF(is_pinf_int, signed long long)
00278 PPL_SPECIALIZE_IS_PINF(is_pinf_int, unsigned char)
00279 PPL_SPECIALIZE_IS_PINF(is_pinf_int, unsigned short)
00280 PPL_SPECIALIZE_IS_PINF(is_pinf_int, unsigned int)
00281 PPL_SPECIALIZE_IS_PINF(is_pinf_int, unsigned long)
00282 PPL_SPECIALIZE_IS_PINF(is_pinf_int, unsigned long long)
00283
00284 template <typename Policy, typename Type>
00285 inline bool
00286 is_int_int(const Type v) {
00287 return !is_nan<Policy>(v);
00288 }
00289
00290 PPL_SPECIALIZE_IS_INT(is_int_int, char)
00291 PPL_SPECIALIZE_IS_INT(is_int_int, signed char)
00292 PPL_SPECIALIZE_IS_INT(is_int_int, signed short)
00293 PPL_SPECIALIZE_IS_INT(is_int_int, signed int)
00294 PPL_SPECIALIZE_IS_INT(is_int_int, signed long)
00295 PPL_SPECIALIZE_IS_INT(is_int_int, signed long long)
00296 PPL_SPECIALIZE_IS_INT(is_int_int, unsigned char)
00297 PPL_SPECIALIZE_IS_INT(is_int_int, unsigned short)
00298 PPL_SPECIALIZE_IS_INT(is_int_int, unsigned int)
00299 PPL_SPECIALIZE_IS_INT(is_int_int, unsigned long)
00300 PPL_SPECIALIZE_IS_INT(is_int_int, unsigned long long)
00301
00302 template <typename Policy, typename Type>
00303 inline Result
00304 assign_special_int(Type& v, Result_Class c, Rounding_Dir dir) {
00305 switch (c) {
00306 case VC_NAN:
00307 if (Policy::has_nan) {
00308 v = Extended_Int<Policy, Type>::not_a_number;
00309 return V_NAN;
00310 }
00311 return V_NAN | V_UNREPRESENTABLE;
00312 case VC_MINUS_INFINITY:
00313 if (Policy::has_infinity) {
00314 v = Extended_Int<Policy, Type>::minus_infinity;
00315 return V_EQ_MINUS_INFINITY;
00316 }
00317 if (round_up(dir)) {
00318 v = Extended_Int<Policy, Type>::min;
00319 return V_LT_INF;
00320 }
00321 return V_EQ_MINUS_INFINITY | V_UNREPRESENTABLE;
00322 case VC_PLUS_INFINITY:
00323 if (Policy::has_infinity) {
00324 v = Extended_Int<Policy, Type>::plus_infinity;
00325 return V_EQ_PLUS_INFINITY;
00326 }
00327 if (round_down(dir)) {
00328 v = Extended_Int<Policy, Type>::max;
00329 return V_GT_SUP;
00330 }
00331 return V_EQ_PLUS_INFINITY | V_UNREPRESENTABLE;
00332 default:
00333 PPL_ASSERT(0);
00334 return V_NAN | V_UNREPRESENTABLE;
00335 }
00336 }
00337
00338 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, char)
00339 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, signed char)
00340 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, signed short)
00341 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, signed int)
00342 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, signed long)
00343 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, signed long long)
00344 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, unsigned char)
00345 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, unsigned short)
00346 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, unsigned int)
00347 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, unsigned long)
00348 PPL_SPECIALIZE_ASSIGN_SPECIAL(assign_special_int, unsigned long long)
00349
00350 template <typename To_Policy, typename From_Policy, typename To, typename From>
00351 inline Result
00352 assign_signed_int_signed_int(To& to, const From from, Rounding_Dir dir) {
00353 if (sizeof(To) < sizeof(From)
00354 || (sizeof(To) == sizeof(From)
00355 && (Extended_Int<To_Policy, To>::min > Extended_Int<From_Policy, From>::min
00356 || Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max))) {
00357 if (CHECK_P(To_Policy::check_overflow,
00358 PPL_LT_SILENT(from, From(Extended_Int<To_Policy, To>::min))))
00359 return set_neg_overflow_int<To_Policy>(to, dir);
00360 if (CHECK_P(To_Policy::check_overflow,
00361 PPL_GT_SILENT(from, From(Extended_Int<To_Policy, To>::max))))
00362 return set_pos_overflow_int<To_Policy>(to, dir);
00363 }
00364 to = To(from);
00365 return V_EQ;
00366 }
00367
00368 template <typename To_Policy, typename From_Policy, typename To, typename From>
00369 inline Result
00370 assign_signed_int_unsigned_int(To& to, const From from, Rounding_Dir dir) {
00371 if (sizeof(To) <= sizeof(From)) {
00372 if (CHECK_P(To_Policy::check_overflow,
00373 from > From(Extended_Int<To_Policy, To>::max)))
00374 return set_pos_overflow_int<To_Policy>(to, dir);
00375 }
00376 to = To(from);
00377 return V_EQ;
00378 }
00379
00380 template <typename To_Policy, typename From_Policy, typename To, typename From>
00381 inline Result
00382 assign_unsigned_int_signed_int(To& to, const From from, Rounding_Dir dir) {
00383 if (CHECK_P(To_Policy::check_overflow, from < 0))
00384 return set_neg_overflow_int<To_Policy>(to, dir);
00385 if (sizeof(To) < sizeof(From)) {
00386 if (CHECK_P(To_Policy::check_overflow,
00387 from > From(Extended_Int<To_Policy, To>::max)))
00388 return set_pos_overflow_int<To_Policy>(to, dir);
00389 }
00390 to = To(from);
00391 return V_EQ;
00392 }
00393
00394 template <typename To_Policy, typename From_Policy, typename To, typename From>
00395 inline Result
00396 assign_unsigned_int_unsigned_int(To& to, const From from, Rounding_Dir dir) {
00397 if (sizeof(To) < sizeof(From)
00398 || (sizeof(To) == sizeof(From)
00399 && Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max)) {
00400 if (CHECK_P(To_Policy::check_overflow,
00401 PPL_GT_SILENT(from, From(Extended_Int<To_Policy, To>::max))))
00402 return set_pos_overflow_int<To_Policy>(to, dir);
00403 }
00404 to = To(from);
00405 return V_EQ;
00406 }
00407
00408
00409 #define PPL_ASSIGN2_SIGNED_SIGNED(Smaller, Larger) \
00410 PPL_SPECIALIZE_ASSIGN(assign_signed_int_signed_int, Smaller, Larger) \
00411 PPL_SPECIALIZE_ASSIGN(assign_signed_int_signed_int, Larger, Smaller)
00412
00413 #define PPL_ASSIGN2_UNSIGNED_UNSIGNED(Smaller, Larger) \
00414 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_unsigned_int, Smaller, Larger) \
00415 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_unsigned_int, Larger, Smaller)
00416
00417 #define PPL_ASSIGN2_UNSIGNED_SIGNED(Smaller, Larger) \
00418 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_signed_int, Smaller, Larger) \
00419 PPL_SPECIALIZE_ASSIGN(assign_signed_int_unsigned_int, Larger, Smaller)
00420
00421 #define PPL_ASSIGN2_SIGNED_UNSIGNED(Smaller, Larger) \
00422 PPL_SPECIALIZE_ASSIGN(assign_signed_int_unsigned_int, Smaller, Larger) \
00423 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_signed_int, Larger, Smaller)
00424
00425 #define PPL_ASSIGN_SIGNED(Type) \
00426 PPL_SPECIALIZE_ASSIGN(assign_signed_int_signed_int, Type, Type)
00427 #define PPL_ASSIGN_UNSIGNED(Type) \
00428 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_unsigned_int, Type, Type)
00429
00430 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
00431 PPL_ASSIGN_SIGNED(char)
00432 #endif
00433 PPL_ASSIGN_SIGNED(signed char)
00434 PPL_ASSIGN_SIGNED(signed short)
00435 PPL_ASSIGN_SIGNED(signed int)
00436 PPL_ASSIGN_SIGNED(signed long)
00437 PPL_ASSIGN_SIGNED(signed long long)
00438 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
00439 PPL_ASSIGN_UNSIGNED(char)
00440 #endif
00441 PPL_ASSIGN_UNSIGNED(unsigned char)
00442 PPL_ASSIGN_UNSIGNED(unsigned short)
00443 PPL_ASSIGN_UNSIGNED(unsigned int)
00444 PPL_ASSIGN_UNSIGNED(unsigned long)
00445 PPL_ASSIGN_UNSIGNED(unsigned long long)
00446
00447 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
00448 PPL_ASSIGN2_SIGNED_SIGNED(char, signed short)
00449 PPL_ASSIGN2_SIGNED_SIGNED(char, signed int)
00450 PPL_ASSIGN2_SIGNED_SIGNED(char, signed long)
00451 PPL_ASSIGN2_SIGNED_SIGNED(char, signed long long)
00452 #endif
00453 PPL_ASSIGN2_SIGNED_SIGNED(signed char, signed short)
00454 PPL_ASSIGN2_SIGNED_SIGNED(signed char, signed int)
00455 PPL_ASSIGN2_SIGNED_SIGNED(signed char, signed long)
00456 PPL_ASSIGN2_SIGNED_SIGNED(signed char, signed long long)
00457 PPL_ASSIGN2_SIGNED_SIGNED(signed short, signed int)
00458 PPL_ASSIGN2_SIGNED_SIGNED(signed short, signed long)
00459 PPL_ASSIGN2_SIGNED_SIGNED(signed short, signed long long)
00460 PPL_ASSIGN2_SIGNED_SIGNED(signed int, signed long)
00461 PPL_ASSIGN2_SIGNED_SIGNED(signed int, signed long long)
00462 PPL_ASSIGN2_SIGNED_SIGNED(signed long, signed long long)
00463 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
00464 PPL_ASSIGN2_UNSIGNED_UNSIGNED(char, unsigned short)
00465 PPL_ASSIGN2_UNSIGNED_UNSIGNED(char, unsigned int)
00466 PPL_ASSIGN2_UNSIGNED_UNSIGNED(char, unsigned long)
00467 PPL_ASSIGN2_UNSIGNED_UNSIGNED(char, unsigned long long)
00468 #endif
00469 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned char, unsigned short)
00470 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned char, unsigned int)
00471 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned char, unsigned long)
00472 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned char, unsigned long long)
00473 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned short, unsigned int)
00474 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned short, unsigned long)
00475 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned short, unsigned long long)
00476 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned int, unsigned long)
00477 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned int, unsigned long long)
00478 PPL_ASSIGN2_UNSIGNED_UNSIGNED(unsigned long, unsigned long long)
00479 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
00480 PPL_ASSIGN2_UNSIGNED_SIGNED(char, signed short)
00481 PPL_ASSIGN2_UNSIGNED_SIGNED(char, signed int)
00482 PPL_ASSIGN2_UNSIGNED_SIGNED(char, signed long)
00483 PPL_ASSIGN2_UNSIGNED_SIGNED(char, signed long long)
00484 #endif
00485 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned char, signed short)
00486 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned char, signed int)
00487 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned char, signed long)
00488 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned char, signed long long)
00489 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned short, signed int)
00490 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned short, signed long)
00491 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned short, signed long long)
00492 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned int, signed long)
00493 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned int, signed long long)
00494 PPL_ASSIGN2_UNSIGNED_SIGNED(unsigned long, signed long long)
00495 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
00496 PPL_ASSIGN2_SIGNED_UNSIGNED(char, unsigned char)
00497 PPL_ASSIGN2_SIGNED_UNSIGNED(char, unsigned short)
00498 PPL_ASSIGN2_SIGNED_UNSIGNED(char, unsigned int)
00499 PPL_ASSIGN2_SIGNED_UNSIGNED(char, unsigned long)
00500 PPL_ASSIGN2_SIGNED_UNSIGNED(char, unsigned long long)
00501 #else
00502 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, char)
00503 #endif
00504 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, unsigned char)
00505 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, unsigned short)
00506 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, unsigned int)
00507 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, unsigned long)
00508 PPL_ASSIGN2_SIGNED_UNSIGNED(signed char, unsigned long long)
00509 PPL_ASSIGN2_SIGNED_UNSIGNED(signed short, unsigned short)
00510 PPL_ASSIGN2_SIGNED_UNSIGNED(signed short, unsigned int)
00511 PPL_ASSIGN2_SIGNED_UNSIGNED(signed short, unsigned long)
00512 PPL_ASSIGN2_SIGNED_UNSIGNED(signed short, unsigned long long)
00513 PPL_ASSIGN2_SIGNED_UNSIGNED(signed int, unsigned int)
00514 PPL_ASSIGN2_SIGNED_UNSIGNED(signed int, unsigned long)
00515 PPL_ASSIGN2_SIGNED_UNSIGNED(signed int, unsigned long long)
00516 PPL_ASSIGN2_SIGNED_UNSIGNED(signed long, unsigned long)
00517 PPL_ASSIGN2_SIGNED_UNSIGNED(signed long, unsigned long long)
00518 PPL_ASSIGN2_SIGNED_UNSIGNED(signed long long, unsigned long long)
00519
00520 template <typename To_Policy, typename From_Policy, typename To, typename From>
00521 inline Result
00522 assign_int_float(To& to, const From from, Rounding_Dir dir) {
00523 if (is_nan<From_Policy>(from))
00524 return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00525 else if (is_minf<From_Policy>(from))
00526 return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00527 else if (is_pinf<From_Policy>(from))
00528 return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00529 #if 0
00530
00531
00532
00533 if (CHECK_P(To_Policy::check_overflow, lt(from, Extended_Int<To_Policy, To>::min)))
00534 return set_neg_overflow_int<To_Policy>(to, dir);
00535 if (CHECK_P(To_Policy::check_overflow, !le(from, Extended_Int<To_Policy, To>::max)))
00536 return set_pos_overflow_int<To_Policy>(to, dir);
00537 #else
00538 if (CHECK_P(To_Policy::check_overflow, (from < Extended_Int<To_Policy, To>::min)))
00539 return set_neg_overflow_int<To_Policy>(to, dir);
00540 if (CHECK_P(To_Policy::check_overflow, (from > Extended_Int<To_Policy, To>::max)))
00541 return set_pos_overflow_int<To_Policy>(to, dir);
00542 #endif
00543 if (round_not_requested(dir)) {
00544 to = from;
00545 return V_LGE;
00546 }
00547 From i_from = rint(from);
00548 to = i_from;
00549 if (from == i_from)
00550 return V_EQ;
00551 if (round_direct(ROUND_UP))
00552 return round_lt_int<To_Policy>(to, dir);
00553 if (round_direct(ROUND_DOWN))
00554 return round_gt_int<To_Policy>(to, dir);
00555 if (from < i_from)
00556 return round_lt_int<To_Policy>(to, dir);
00557 if (from > i_from)
00558 return round_gt_int<To_Policy>(to, dir);
00559 PPL_ASSERT(false);
00560 return V_NAN;
00561 }
00562
00563 PPL_SPECIALIZE_ASSIGN(assign_int_float, char, float)
00564 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed char, float)
00565 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed short, float)
00566 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed int, float)
00567 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long, float)
00568 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long long, float)
00569 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned char, float)
00570 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned short, float)
00571 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned int, float)
00572 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long, float)
00573 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long long, float)
00574
00575 PPL_SPECIALIZE_ASSIGN(assign_int_float, char, double)
00576 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed char, double)
00577 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed short, double)
00578 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed int, double)
00579 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long, double)
00580 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long long, double)
00581 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned char, double)
00582 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned short, double)
00583 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned int, double)
00584 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long, double)
00585 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long long, double)
00586
00587 PPL_SPECIALIZE_ASSIGN(assign_int_float, char, long double)
00588 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed char, long double)
00589 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed short, long double)
00590 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed int, long double)
00591 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long, long double)
00592 PPL_SPECIALIZE_ASSIGN(assign_int_float, signed long long, long double)
00593 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned char, long double)
00594 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned short, long double)
00595 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned int, long double)
00596 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long, long double)
00597 PPL_SPECIALIZE_ASSIGN(assign_int_float, unsigned long long, long double)
00598
00599 #undef PPL_ASSIGN_SIGNED
00600 #undef PPL_ASSIGN_UNSIGNED
00601 #undef PPL_ASSIGN2_SIGNED_SIGNED
00602 #undef PPL_ASSIGN2_UNSIGNED_UNSIGNED
00603 #undef PPL_ASSIGN2_UNSIGNED_SIGNED
00604 #undef PPL_ASSIGN2_SIGNED_UNSIGNED
00605
00606 template <typename To_Policy, typename From_Policy, typename To>
00607 inline Result
00608 assign_signed_int_mpz(To& to, const mpz_class& from, Rounding_Dir dir) {
00609 if (sizeof(To) <= sizeof(signed long)) {
00610 if (!To_Policy::check_overflow) {
00611 to = from.get_si();
00612 return V_EQ;
00613 }
00614 if (from.fits_slong_p()) {
00615 signed long v = from.get_si();
00616 if (PPL_LT_SILENT(v, (Extended_Int<To_Policy, To>::min)))
00617 return set_neg_overflow_int<To_Policy>(to, dir);
00618 if (PPL_GT_SILENT(v, (Extended_Int<To_Policy, To>::max)))
00619 return set_pos_overflow_int<To_Policy>(to, dir);
00620 to = v;
00621 return V_EQ;
00622 }
00623 }
00624 else {
00625 mpz_srcptr m = from.get_mpz_t();
00626 size_t sz = mpz_size(m);
00627 if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
00628 if (sz == 0) {
00629 to = 0;
00630 return V_EQ;
00631 }
00632 To v;
00633 mpz_export(&v, 0, -1, sizeof(To), 0, 0, m);
00634 if (v >= 0) {
00635 if (::sgn(from) < 0)
00636 return neg<To_Policy, To_Policy>(to, v, dir);
00637 to = v;
00638 return V_EQ;
00639 }
00640 }
00641 }
00642 return ::sgn(from) < 0
00643 ? set_neg_overflow_int<To_Policy>(to, dir)
00644 : set_pos_overflow_int<To_Policy>(to, dir);
00645 }
00646
00647 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
00648 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, char, mpz_class)
00649 #endif
00650 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, signed char, mpz_class)
00651 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, signed short, mpz_class)
00652 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, signed int, mpz_class)
00653 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, signed long, mpz_class)
00654 PPL_SPECIALIZE_ASSIGN(assign_signed_int_mpz, signed long long, mpz_class)
00655
00656 template <typename To_Policy, typename From_Policy, typename To>
00657 inline Result
00658 assign_unsigned_int_mpz(To& to, const mpz_class& from, Rounding_Dir dir) {
00659 if (CHECK_P(To_Policy::check_overflow, ::sgn(from) < 0))
00660 return set_neg_overflow_int<To_Policy>(to, dir);
00661 if (sizeof(To) <= sizeof(unsigned long)) {
00662 if (!To_Policy::check_overflow) {
00663 to = from.get_ui();
00664 return V_EQ;
00665 }
00666 if (from.fits_ulong_p()) {
00667 unsigned long v = from.get_ui();
00668 if (PPL_GT_SILENT(v, (Extended_Int<To_Policy, To>::max)))
00669 return set_pos_overflow_int<To_Policy>(to, dir);
00670 to = v;
00671 return V_EQ;
00672 }
00673 }
00674 else {
00675 mpz_srcptr m = from.get_mpz_t();
00676 size_t sz = mpz_size(m);
00677 if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
00678 if (sz == 0)
00679 to = 0;
00680 else
00681 mpz_export(&to, 0, -1, sizeof(To), 0, 0, m);
00682 return V_EQ;
00683 }
00684 }
00685 return set_pos_overflow_int<To_Policy>(to, dir);
00686 }
00687
00688 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
00689 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, char, mpz_class)
00690 #endif
00691 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, unsigned char, mpz_class)
00692 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, unsigned short, mpz_class)
00693 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, unsigned int, mpz_class)
00694 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, unsigned long, mpz_class)
00695 PPL_SPECIALIZE_ASSIGN(assign_unsigned_int_mpz, unsigned long long, mpz_class)
00696
00697 template <typename To_Policy, typename From_Policy, typename To>
00698 inline Result
00699 assign_int_mpq(To& to, const mpq_class& from, Rounding_Dir dir) {
00700 mpz_srcptr n = from.get_num().get_mpz_t();
00701 mpz_srcptr d = from.get_den().get_mpz_t();
00702 PPL_DIRTY_TEMP0(mpz_class, q);
00703 mpz_ptr _q = q.get_mpz_t();
00704 if (round_not_requested(dir)) {
00705 mpz_tdiv_q(_q, n, d);
00706 Result r = assign<To_Policy, void>(to, q, dir);
00707 if (r != V_EQ)
00708 return r;
00709 return V_LGE;
00710 }
00711 mpz_t rem;
00712 int sign;
00713 mpz_init(rem);
00714 mpz_tdiv_qr(_q, rem, n, d);
00715 sign = mpz_sgn(rem);
00716 mpz_clear(rem);
00717 Result r = assign<To_Policy, void>(to, q, dir);
00718 if (r != V_EQ)
00719 return r;
00720 switch (sign) {
00721 case -1:
00722 return round_lt_int<To_Policy>(to, dir);
00723 case 1:
00724 return round_gt_int<To_Policy>(to, dir);
00725 default:
00726 return V_EQ;
00727 }
00728 }
00729
00730 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, char, mpq_class)
00731 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, signed char, mpq_class)
00732 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, signed short, mpq_class)
00733 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, signed int, mpq_class)
00734 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, signed long, mpq_class)
00735 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, signed long long, mpq_class)
00736 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, unsigned char, mpq_class)
00737 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, unsigned short, mpq_class)
00738 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, unsigned int, mpq_class)
00739 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, unsigned long, mpq_class)
00740 PPL_SPECIALIZE_ASSIGN(assign_int_mpq, unsigned long long, mpq_class)
00741
00742 #if ~0 != -1
00743 #error "Only two's complement is supported"
00744 #endif
00745
00746 #if UCHAR_MAX == 0xff
00747 #define CHAR_BITS 8
00748 #else
00749 #error "Unexpected max for unsigned char"
00750 #endif
00751
00752 #if USHRT_MAX == 0xffff
00753 #define SHRT_BITS 16
00754 #else
00755 #error "Unexpected max for unsigned short"
00756 #endif
00757
00758 #if UINT_MAX == 0xffffffff
00759 #define INT_BITS 32
00760 #else
00761 #error "Unexpected max for unsigned int"
00762 #endif
00763
00764 #if ULONG_MAX == 0xffffffffUL
00765 #define LONG_BITS 32
00766 #elif ULONG_MAX == 0xffffffffffffffffULL
00767 #define LONG_BITS 64
00768 #else
00769 #error "Unexpected max for unsigned long"
00770 #endif
00771
00772 #if ULLONG_MAX == 0xffffffffffffffffULL
00773 #define LONG_LONG_BITS 64
00774 #else
00775 #error "Unexpected max for unsigned long long"
00776 #endif
00777
00778
00779 template <typename T>
00780 struct Larger;
00781
00782
00783
00784
00785
00786
00787
00788 template <>
00789 struct Larger<char> {
00790 const_bool_nodef(use_for_neg, true);
00791 const_bool_nodef(use_for_add, true);
00792 const_bool_nodef(use_for_sub, true);
00793 const_bool_nodef(use_for_mul, true);
00794 typedef int_fast16_t type_for_neg;
00795 typedef int_fast16_t type_for_add;
00796 typedef int_fast16_t type_for_sub;
00797 typedef int_fast16_t type_for_mul;
00798 };
00799
00800 template <>
00801 struct Larger<signed char> {
00802 const_bool_nodef(use_for_neg, true);
00803 const_bool_nodef(use_for_add, true);
00804 const_bool_nodef(use_for_sub, true);
00805 const_bool_nodef(use_for_mul, true);
00806 typedef int_fast16_t type_for_neg;
00807 typedef int_fast16_t type_for_add;
00808 typedef int_fast16_t type_for_sub;
00809 typedef int_fast16_t type_for_mul;
00810 };
00811
00812 template <>
00813 struct Larger<unsigned char> {
00814 const_bool_nodef(use_for_neg, true);
00815 const_bool_nodef(use_for_add, true);
00816 const_bool_nodef(use_for_sub, true);
00817 const_bool_nodef(use_for_mul, true);
00818 typedef int_fast16_t type_for_neg;
00819 typedef uint_fast16_t type_for_add;
00820 typedef int_fast16_t type_for_sub;
00821 typedef uint_fast16_t type_for_mul;
00822 };
00823
00824 template <>
00825 struct Larger<signed short> {
00826 const_bool_nodef(use_for_neg, true);
00827 const_bool_nodef(use_for_add, true);
00828 const_bool_nodef(use_for_sub, true);
00829 const_bool_nodef(use_for_mul, true);
00830 typedef int_fast32_t type_for_neg;
00831 typedef int_fast32_t type_for_add;
00832 typedef int_fast32_t type_for_sub;
00833 typedef int_fast32_t type_for_mul;
00834 };
00835
00836 template <>
00837 struct Larger<unsigned short> {
00838 const_bool_nodef(use_for_neg, true);
00839 const_bool_nodef(use_for_add, true);
00840 const_bool_nodef(use_for_sub, true);
00841 const_bool_nodef(use_for_mul, true);
00842 typedef int_fast32_t type_for_neg;
00843 typedef uint_fast32_t type_for_add;
00844 typedef int_fast32_t type_for_sub;
00845 typedef uint_fast32_t type_for_mul;
00846 };
00847
00848 template <>
00849 struct Larger<signed int> {
00850 const_bool_nodef(use_for_neg, (LONG_BITS == 64));
00851 const_bool_nodef(use_for_add, (LONG_BITS == 64));
00852 const_bool_nodef(use_for_sub, (LONG_BITS == 64));
00853 const_bool_nodef(use_for_mul, true);
00854 typedef int_fast64_t type_for_neg;
00855 typedef int_fast64_t type_for_add;
00856 typedef int_fast64_t type_for_sub;
00857 typedef int_fast64_t type_for_mul;
00858 };
00859
00860 template <>
00861 struct Larger<unsigned int> {
00862 const_bool_nodef(use_for_neg, (LONG_BITS == 64));
00863 const_bool_nodef(use_for_add, (LONG_BITS == 64));
00864 const_bool_nodef(use_for_sub, (LONG_BITS == 64));
00865 const_bool_nodef(use_for_mul, true);
00866 typedef int_fast64_t type_for_neg;
00867 typedef uint_fast64_t type_for_add;
00868 typedef int_fast64_t type_for_sub;
00869 typedef uint_fast64_t type_for_mul;
00870 };
00871
00872 template <>
00873 struct Larger<signed long> {
00874 const_bool_nodef(use_for_neg, false);
00875 const_bool_nodef(use_for_add, false);
00876 const_bool_nodef(use_for_sub, false);
00877 const_bool_nodef(use_for_mul, (LONG_BITS == 32));
00878 typedef int_fast64_t type_for_neg;
00879 typedef int_fast64_t type_for_add;
00880 typedef int_fast64_t type_for_sub;
00881 typedef int_fast64_t type_for_mul;
00882 };
00883
00884 template <>
00885 struct Larger<unsigned long> {
00886 const_bool_nodef(use_for_neg, false);
00887 const_bool_nodef(use_for_add, false);
00888 const_bool_nodef(use_for_sub, false);
00889 const_bool_nodef(use_for_mul, (LONG_BITS == 32));
00890 typedef int_fast64_t type_for_neg;
00891 typedef uint_fast64_t type_for_add;
00892 typedef int_fast64_t type_for_sub;
00893 typedef uint_fast64_t type_for_mul;
00894 };
00895
00896 template <>
00897 struct Larger<signed long long> {
00898 const_bool_nodef(use_for_neg, false);
00899 const_bool_nodef(use_for_add, false);
00900 const_bool_nodef(use_for_sub, false);
00901 const_bool_nodef(use_for_mul, false);
00902 typedef int_fast64_t type_for_neg;
00903 typedef int_fast64_t type_for_add;
00904 typedef int_fast64_t type_for_sub;
00905 typedef int_fast64_t type_for_mul;
00906 };
00907
00908 template <>
00909 struct Larger<unsigned long long> {
00910 const_bool_nodef(use_for_neg, false);
00911 const_bool_nodef(use_for_add, false);
00912 const_bool_nodef(use_for_sub, false);
00913 const_bool_nodef(use_for_mul, false);
00914 typedef int_fast64_t type_for_neg;
00915 typedef uint_fast64_t type_for_add;
00916 typedef int_fast64_t type_for_sub;
00917 typedef uint_fast64_t type_for_mul;
00918 };
00919
00920 template <typename To_Policy, typename From_Policy, typename Type>
00921 inline Result
00922 neg_int_larger(Type& to, const Type x, Rounding_Dir dir) {
00923 typename Larger<Type>::type_for_neg l = x;
00924 l = -l;
00925 return assign<To_Policy, To_Policy>(to, l, dir);
00926 }
00927
00928 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
00929 inline Result
00930 add_int_larger(Type& to, const Type x, const Type y, Rounding_Dir dir) {
00931 typename Larger<Type>::type_for_add l = x;
00932 l += y;
00933 return assign<To_Policy, To_Policy>(to, l, dir);
00934 }
00935
00936 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
00937 inline Result
00938 sub_int_larger(Type& to, const Type x, const Type y, Rounding_Dir dir) {
00939 typename Larger<Type>::type_for_sub l = x;
00940 l -= y;
00941 return assign<To_Policy, To_Policy>(to, l, dir);
00942 }
00943
00944 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
00945 inline Result
00946 mul_int_larger(Type& to, const Type x, const Type y, Rounding_Dir dir) {
00947 typename Larger<Type>::type_for_mul l = x;
00948 l *= y;
00949 return assign<To_Policy, To_Policy>(to, l, dir);
00950 }
00951
00952 template <typename To_Policy, typename From_Policy, typename Type>
00953 inline Result
00954 neg_signed_int(Type& to, const Type from, Rounding_Dir dir) {
00955 if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
00956 return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
00957 if (CHECK_P(To_Policy::check_overflow,
00958 (from < -Extended_Int<To_Policy, Type>::max)))
00959 return set_pos_overflow_int<To_Policy>(to, dir);
00960 to = -from;
00961 return V_EQ;
00962 }
00963
00964 template <typename To_Policy, typename From_Policy, typename Type>
00965 inline Result
00966 neg_unsigned_int(Type& to, const Type from, Rounding_Dir dir) {
00967 if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
00968 return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
00969 if (CHECK_P(To_Policy::check_overflow, from != 0))
00970 return set_neg_overflow_int<To_Policy>(to, dir);
00971 to = from;
00972 return V_EQ;
00973 }
00974
00975 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
00976 inline Result
00977 add_signed_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
00978 if (To_Policy::check_overflow && Larger<Type>::use_for_add)
00979 return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00980 if (To_Policy::check_overflow) {
00981 if (y >= 0) {
00982 if (x > Extended_Int<To_Policy, Type>::max - y)
00983 return set_pos_overflow_int<To_Policy>(to, dir);
00984 }
00985 else if (x < Extended_Int<To_Policy, Type>::min - y)
00986 return set_neg_overflow_int<To_Policy>(to, dir);
00987 }
00988 to = x + y;
00989 return V_EQ;
00990 }
00991
00992 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
00993 inline Result
00994 add_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
00995 if (To_Policy::check_overflow && Larger<Type>::use_for_add)
00996 return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00997 if (CHECK_P(To_Policy::check_overflow,
00998 (x > Extended_Int<To_Policy, Type>::max - y)))
00999 return set_pos_overflow_int<To_Policy>(to, dir);
01000 to = x + y;
01001 return V_EQ;
01002 }
01003
01004 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01005 inline Result
01006 sub_signed_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01007 if (To_Policy::check_overflow && Larger<Type>::use_for_sub)
01008 return sub_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
01009 if (To_Policy::check_overflow) {
01010 if (y >= 0) {
01011 if (x < Extended_Int<To_Policy, Type>::min + y)
01012 return set_neg_overflow_int<To_Policy>(to, dir);
01013 }
01014 else if (x > Extended_Int<To_Policy, Type>::max + y)
01015 return set_pos_overflow_int<To_Policy>(to, dir);
01016 }
01017 to = x - y;
01018 return V_EQ;
01019 }
01020
01021 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01022 inline Result
01023 sub_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01024 if (To_Policy::check_overflow && Larger<Type>::use_for_sub)
01025 return sub_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
01026 if (CHECK_P(To_Policy::check_overflow,
01027 (x < Extended_Int<To_Policy, Type>::min + y)))
01028 return set_neg_overflow_int<To_Policy>(to, dir);
01029 to = x - y;
01030 return V_EQ;
01031 }
01032
01033 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01034 inline Result
01035 mul_signed_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01036 if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
01037 return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
01038 if (!To_Policy::check_overflow) {
01039 to = x * y;
01040 return V_EQ;
01041 }
01042 if (y == 0) {
01043 to = 0;
01044 return V_EQ;
01045 }
01046 if (y == -1)
01047 return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
01048 if (x >= 0) {
01049 if (y > 0) {
01050 if (x > Extended_Int<To_Policy, Type>::max / y)
01051 return set_pos_overflow_int<To_Policy>(to, dir);
01052 }
01053 else {
01054 if (x > Extended_Int<To_Policy, Type>::min / y)
01055 return set_neg_overflow_int<To_Policy>(to, dir);
01056 }
01057 }
01058 else {
01059 if (y < 0) {
01060 if (x < Extended_Int<To_Policy, Type>::max / y)
01061 return set_pos_overflow_int<To_Policy>(to, dir);
01062 }
01063 else {
01064 if (x < Extended_Int<To_Policy, Type>::min / y)
01065 return set_neg_overflow_int<To_Policy>(to, dir);
01066 }
01067 }
01068 to = x * y;
01069 return V_EQ;
01070 }
01071
01072 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01073 inline Result
01074 mul_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01075 if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
01076 return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
01077 if (!To_Policy::check_overflow) {
01078 to = x * y;
01079 return V_EQ;
01080 }
01081 if (y == 0) {
01082 to = 0;
01083 return V_EQ;
01084 }
01085 if (x > Extended_Int<To_Policy, Type>::max / y)
01086 return set_pos_overflow_int<To_Policy>(to, dir);
01087 to = x * y;
01088 return V_EQ;
01089 }
01090
01091 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01092 inline Result
01093 div_signed_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01094 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01095 return assign_nan<To_Policy>(to, V_DIV_ZERO);
01096 }
01097 if (To_Policy::check_overflow && y == -1)
01098 return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
01099 to = x / y;
01100 if (round_not_requested(dir))
01101 return V_LGE;
01102 Type m = x % y;
01103 if (m < 0)
01104 return round_lt_int_no_overflow<To_Policy>(to, dir);
01105 else if (m > 0)
01106 return round_gt_int_no_overflow<To_Policy>(to, dir);
01107 else
01108 return V_EQ;
01109 }
01110
01111 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01112 inline Result
01113 div_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01114 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01115 return assign_nan<To_Policy>(to, V_DIV_ZERO);
01116 }
01117 to = x / y;
01118 if (round_not_requested(dir))
01119 return V_GE;
01120 Type m = x % y;
01121 if (m == 0)
01122 return V_EQ;
01123 return round_gt_int<To_Policy>(to, dir);
01124 }
01125
01126 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01127 inline Result
01128 idiv_signed_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01129 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01130 return assign_nan<To_Policy>(to, V_DIV_ZERO);
01131 }
01132 if (To_Policy::check_overflow && y == -1)
01133 return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
01134 to = x / y;
01135 return V_EQ;
01136 }
01137
01138 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01139 inline Result
01140 idiv_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir) {
01141 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01142 return assign_nan<To_Policy>(to, V_DIV_ZERO);
01143 }
01144 to = x / y;
01145 return V_EQ;
01146 }
01147
01148 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01149 inline Result
01150 rem_signed_int(Type& to, const Type x, const Type y, Rounding_Dir) {
01151 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01152 return assign_nan<To_Policy>(to, V_MOD_ZERO);
01153 }
01154 to = x % y;
01155 return V_EQ;
01156 }
01157
01158 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01159 inline Result
01160 rem_unsigned_int(Type& to, const Type x, const Type y, Rounding_Dir) {
01161 if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
01162 return assign_nan<To_Policy>(to, V_MOD_ZERO);
01163 }
01164 to = x % y;
01165 return V_EQ;
01166 }
01167
01168 template <typename To_Policy, typename From_Policy, typename Type>
01169 inline Result
01170 div_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01171 Rounding_Dir dir) {
01172 if (exp >= sizeof(Type) * CHAR_BIT) {
01173 to = 0;
01174 if (round_not_requested(dir))
01175 return V_GE;
01176 if (x == 0)
01177 return V_EQ;
01178 return round_gt_int_no_overflow<To_Policy>(to, dir);
01179 }
01180 to = x >> exp;
01181 if (round_not_requested(dir))
01182 return V_GE;
01183 if (x & ((Type(1) << exp) - 1))
01184 return round_gt_int_no_overflow<To_Policy>(to, dir);
01185 else
01186 return V_EQ;
01187 }
01188
01189 template <typename To_Policy, typename From_Policy, typename Type>
01190 inline Result
01191 div_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01192 Rounding_Dir dir) {
01193 if (exp > sizeof(Type) * CHAR_BIT - 1) {
01194 zero:
01195 to = 0;
01196 if (round_not_requested(dir))
01197 return V_LGE;
01198 if (x < 0)
01199 return round_lt_int_no_overflow<To_Policy>(to, dir);
01200 else if (x > 0)
01201 return round_gt_int_no_overflow<To_Policy>(to, dir);
01202 else
01203 return V_EQ;
01204 }
01205 if (exp == sizeof(Type) * CHAR_BIT - 1) {
01206 if (x == C_Integer<Type>::min) {
01207 to = -1;
01208 return V_EQ;
01209 }
01210 goto zero;
01211 }
01212 #if 0
01213 to = x / (Type(1) << exp);
01214 if (round_not_requested(dir))
01215 return V_GE;
01216 Type r = x % (Type(1) << exp);
01217 if (r < 0)
01218 return round_lt_int_no_overflow<To_Policy>(to, dir);
01219 else if (r > 0)
01220 return round_gt_int_no_overflow<To_Policy>(to, dir);
01221 else
01222 return V_EQ;
01223 #else
01224
01225 to = x >> exp;
01226 if (round_not_requested(dir))
01227 return V_GE;
01228 if (x & ((Type(1) << exp) - 1))
01229 return round_gt_int_no_overflow<To_Policy>(to, dir);
01230 return V_EQ;
01231 #endif
01232 }
01233
01234 template <typename To_Policy, typename From_Policy, typename Type>
01235 inline Result
01236 add_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01237 Rounding_Dir dir) {
01238 if (!To_Policy::check_overflow) {
01239 to = x + (Type(1) << exp);
01240 return V_EQ;
01241 }
01242 if (exp >= sizeof(Type) * CHAR_BIT)
01243 return set_pos_overflow_int<To_Policy>(to, dir);
01244 Type n = Type(1) << exp;
01245 return add_unsigned_int<To_Policy, From_Policy, void>(to, x, n, dir);
01246 }
01247
01248 template <typename To_Policy, typename From_Policy, typename Type>
01249 inline Result
01250 add_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01251 Rounding_Dir dir) {
01252 if (!To_Policy::check_overflow) {
01253 to = x + (Type(1) << exp);
01254 return V_EQ;
01255 }
01256 if (exp >= sizeof(Type) * CHAR_BIT)
01257 return set_pos_overflow_int<To_Policy>(to, dir);
01258 if (exp == sizeof(Type) * CHAR_BIT - 1) {
01259 Type n = -2 * (Type(1) << (exp - 1));
01260 return sub_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
01261 }
01262 else {
01263 Type n = Type(1) << exp;
01264 return add_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
01265 }
01266 }
01267
01268 template <typename To_Policy, typename From_Policy, typename Type>
01269 inline Result
01270 sub_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01271 Rounding_Dir dir) {
01272 if (!To_Policy::check_overflow) {
01273 to = x - (Type(1) << exp);
01274 return V_EQ;
01275 }
01276 if (exp >= sizeof(Type) * CHAR_BIT)
01277 return set_neg_overflow_int<To_Policy>(to, dir);
01278 Type n = Type(1) << exp;
01279 return sub_unsigned_int<To_Policy, From_Policy, void>(to, x, n, dir);
01280 }
01281
01282 template <typename To_Policy, typename From_Policy, typename Type>
01283 inline Result
01284 sub_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01285 Rounding_Dir dir) {
01286 if (!To_Policy::check_overflow) {
01287 to = x - (Type(1) << exp);
01288 return V_EQ;
01289 }
01290 if (exp >= sizeof(Type) * CHAR_BIT)
01291 return set_neg_overflow_int<To_Policy>(to, dir);
01292 if (exp == sizeof(Type) * CHAR_BIT - 1) {
01293 Type n = -2 * (Type(1) << (exp - 1));
01294 return add_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
01295 }
01296 else {
01297 Type n = Type(1) << exp;
01298 return sub_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
01299 }
01300 }
01301
01302 template <typename To_Policy, typename From_Policy, typename Type>
01303 inline Result
01304 mul_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01305 Rounding_Dir dir) {
01306 if (!To_Policy::check_overflow) {
01307 to = x << exp;
01308 return V_EQ;
01309 }
01310 if (exp >= sizeof(Type) * CHAR_BIT) {
01311 if (x == 0) {
01312 to = 0;
01313 return V_EQ;
01314 }
01315 return set_pos_overflow_int<To_Policy>(to, dir);
01316 }
01317 if (x & (((Type(1) << exp) - 1) << (sizeof(Type) * CHAR_BIT - exp)))
01318 return set_pos_overflow_int<To_Policy>(to, dir);
01319 Type n = x << exp;
01320 if (PPL_GT_SILENT(n, (Extended_Int<To_Policy, Type>::max)))
01321 return set_pos_overflow_int<To_Policy>(to, dir);
01322 to = n;
01323 return V_EQ;
01324 }
01325
01326 template <typename To_Policy, typename From_Policy, typename Type>
01327 inline Result
01328 mul_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01329 Rounding_Dir dir) {
01330 if (!To_Policy::check_overflow) {
01331 to = x << exp;
01332 return V_EQ;
01333 }
01334 if (exp >= sizeof(Type) * CHAR_BIT - 1) {
01335 if (x < 0)
01336 return set_neg_overflow_int<To_Policy>(to, dir);
01337 else if (x > 0)
01338 return set_pos_overflow_int<To_Policy>(to, dir);
01339 else {
01340 to = 0;
01341 return V_EQ;
01342 }
01343 }
01344 Type mask = ((Type(1) << exp) - 1)
01345 << (sizeof(Type) * CHAR_BIT - 1 - exp);
01346 Type n;
01347 if (x < 0) {
01348 if ((x & mask) != mask)
01349 return set_neg_overflow_int<To_Policy>(to, dir);
01350 n = x << exp;
01351 if (PPL_LT_SILENT(n, (Extended_Int<To_Policy, Type>::min)))
01352 return set_neg_overflow_int<To_Policy>(to, dir);
01353 }
01354 else {
01355 if (x & mask)
01356 return set_pos_overflow_int<To_Policy>(to, dir);
01357 n = x << exp;
01358 if (PPL_GT_SILENT(n, (Extended_Int<To_Policy, Type>::max)))
01359 return set_pos_overflow_int<To_Policy>(to, dir);
01360 }
01361 to = n;
01362 return V_EQ;
01363 }
01364
01365 template <typename To_Policy, typename From_Policy, typename Type>
01366 inline Result
01367 smod_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01368 Rounding_Dir dir) {
01369 if (exp > sizeof(Type) * CHAR_BIT)
01370 to = x;
01371 else {
01372 Type v = exp == sizeof(Type) * CHAR_BIT ? x : (x & ((Type(1) << exp) - 1));
01373 if (v >= Type(1) << (exp - 1))
01374 return set_neg_overflow_int<To_Policy>(to, dir);
01375 else
01376 to = v;
01377 }
01378 return V_EQ;
01379 }
01380
01381 template <typename To_Policy, typename From_Policy, typename Type>
01382 inline Result
01383 smod_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01384 Rounding_Dir) {
01385 if (exp >= sizeof(Type) * CHAR_BIT)
01386 to = x;
01387 else {
01388 Type m = Type(1) << (exp - 1);
01389 to = (x & (m - 1)) - (x & m);
01390 }
01391 return V_EQ;
01392 }
01393
01394 template <typename To_Policy, typename From_Policy, typename Type>
01395 inline Result
01396 umod_2exp_unsigned_int(Type& to, const Type x, unsigned int exp,
01397 Rounding_Dir) {
01398 if (exp >= sizeof(Type) * CHAR_BIT)
01399 to = x;
01400 else
01401 to = x & ((Type(1) << exp) - 1);
01402 return V_EQ;
01403 }
01404
01405 template <typename To_Policy, typename From_Policy, typename Type>
01406 inline Result
01407 umod_2exp_signed_int(Type& to, const Type x, unsigned int exp,
01408 Rounding_Dir dir) {
01409 if (exp >= sizeof(Type) * CHAR_BIT) {
01410 if (x < 0)
01411 return set_pos_overflow_int<To_Policy>(to, dir);
01412 to = x;
01413 }
01414 else
01415 to = x & ((Type(1) << exp) - 1);
01416 return V_EQ;
01417 }
01418
01419 template <typename Type>
01420 inline void
01421 isqrtrem(Type& q, Type& r, const Type from) {
01422 q = 0;
01423 r = from;
01424 Type t(1);
01425 for (t <<= CHAR_BIT * sizeof(Type) - 2; t != 0; t >>= 2) {
01426 Type s = q + t;
01427 if (s <= r) {
01428 r -= s;
01429 q = s + t;
01430 }
01431 q >>= 1;
01432 }
01433 }
01434
01435 template <typename To_Policy, typename From_Policy, typename Type>
01436 inline Result
01437 sqrt_unsigned_int(Type& to, const Type from, Rounding_Dir dir) {
01438 Type rem;
01439 isqrtrem(to, rem, from);
01440 if (round_not_requested(dir))
01441 return V_GE;
01442 if (rem == 0)
01443 return V_EQ;
01444 return round_gt_int<To_Policy>(to, dir);
01445 }
01446
01447 template <typename To_Policy, typename From_Policy, typename Type>
01448 inline Result
01449 sqrt_signed_int(Type& to, const Type from, Rounding_Dir dir) {
01450 if (CHECK_P(To_Policy::check_sqrt_neg, from < 0)) {
01451 return assign_nan<To_Policy>(to, V_SQRT_NEG);
01452 }
01453 return sqrt_unsigned_int<To_Policy, From_Policy>(to, from, dir);
01454 }
01455
01456 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01457 inline Result
01458 add_mul_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01459 Type z;
01460 Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
01461 switch (result_overflow(r)) {
01462 case 0:
01463 return add<To_Policy, To_Policy, To_Policy>(to, to, z, dir);
01464 case -1:
01465 if (to <= 0)
01466 return set_neg_overflow_int<To_Policy>(to, dir);
01467 return assign_nan<To_Policy>(to, V_UNKNOWN_NEG_OVERFLOW);
01468 case 1:
01469 if (to >= 0)
01470 return set_pos_overflow_int<To_Policy>(to, dir);
01471 return assign_nan<To_Policy>(to, V_UNKNOWN_POS_OVERFLOW);
01472 default:
01473 PPL_ASSERT(false);
01474 return V_NAN;
01475 }
01476 }
01477
01478 template <typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
01479 inline Result
01480 sub_mul_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
01481 Type z;
01482 Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
01483 switch (result_overflow(r)) {
01484 case 0:
01485 return sub<To_Policy, To_Policy, To_Policy>(to, to, z, dir);
01486 case -1:
01487 if (to >= 0)
01488 return set_pos_overflow_int<To_Policy>(to, dir);
01489 return assign_nan<To_Policy>(to, V_UNKNOWN_NEG_OVERFLOW);
01490 case 1:
01491 if (to <= 0)
01492 return set_neg_overflow_int<To_Policy>(to, dir);
01493 return assign_nan<To_Policy>(to, V_UNKNOWN_POS_OVERFLOW);
01494 default:
01495 PPL_ASSERT(false);
01496 return V_NAN;
01497 }
01498 }
01499
01500 template <typename Policy, typename Type>
01501 inline Result
01502 output_char(std::ostream& os, Type& from,
01503 const Numeric_Format&, Rounding_Dir) {
01504 os << int(from);
01505 return V_EQ;
01506 }
01507
01508 template <typename Policy, typename Type>
01509 inline Result
01510 output_int(std::ostream& os, Type& from, const Numeric_Format&, Rounding_Dir) {
01511 os << from;
01512 return V_EQ;
01513 }
01514
01515 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01516 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, char, char)
01517 #endif
01518 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, signed char, signed char)
01519 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, signed short, signed short)
01520 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, signed int, signed int)
01521 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, signed long, signed long)
01522 PPL_SPECIALIZE_FLOOR(assign_signed_int_signed_int, signed long long, signed long long)
01523 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01524 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, char, char)
01525 #endif
01526 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, unsigned char, unsigned char)
01527 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, unsigned short, unsigned short)
01528 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, unsigned int, unsigned int)
01529 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, unsigned long, unsigned long)
01530 PPL_SPECIALIZE_FLOOR(assign_unsigned_int_unsigned_int, unsigned long long, unsigned long long)
01531
01532 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01533 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, char, char)
01534 #endif
01535 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, signed char, signed char)
01536 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, signed short, signed short)
01537 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, signed int, signed int)
01538 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, signed long, signed long)
01539 PPL_SPECIALIZE_CEIL(assign_signed_int_signed_int, signed long long, signed long long)
01540 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01541 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, char, char)
01542 #endif
01543 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, unsigned char, unsigned char)
01544 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, unsigned short, unsigned short)
01545 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, unsigned int, unsigned int)
01546 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, unsigned long, unsigned long)
01547 PPL_SPECIALIZE_CEIL(assign_unsigned_int_unsigned_int, unsigned long long, unsigned long long)
01548
01549 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01550 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, char, char)
01551 #endif
01552 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, signed char, signed char)
01553 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, signed short, signed short)
01554 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, signed int, signed int)
01555 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, signed long, signed long)
01556 PPL_SPECIALIZE_TRUNC(assign_signed_int_signed_int, signed long long, signed long long)
01557 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01558 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, char, char)
01559 #endif
01560 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, unsigned char, unsigned char)
01561 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, unsigned short, unsigned short)
01562 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, unsigned int, unsigned int)
01563 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, unsigned long, unsigned long)
01564 PPL_SPECIALIZE_TRUNC(assign_unsigned_int_unsigned_int, unsigned long long, unsigned long long)
01565
01566 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01567 PPL_SPECIALIZE_NEG(neg_signed_int, char, char)
01568 #endif
01569 PPL_SPECIALIZE_NEG(neg_signed_int, signed char, signed char)
01570 PPL_SPECIALIZE_NEG(neg_signed_int, signed short, signed short)
01571 PPL_SPECIALIZE_NEG(neg_signed_int, signed int, signed int)
01572 PPL_SPECIALIZE_NEG(neg_signed_int, signed long, signed long)
01573 PPL_SPECIALIZE_NEG(neg_signed_int, signed long long, signed long long)
01574 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01575 PPL_SPECIALIZE_NEG(neg_unsigned_int, char, char)
01576 #endif
01577 PPL_SPECIALIZE_NEG(neg_unsigned_int, unsigned char, unsigned char)
01578 PPL_SPECIALIZE_NEG(neg_unsigned_int, unsigned short, unsigned short)
01579 PPL_SPECIALIZE_NEG(neg_unsigned_int, unsigned int, unsigned int)
01580 PPL_SPECIALIZE_NEG(neg_unsigned_int, unsigned long, unsigned long)
01581 PPL_SPECIALIZE_NEG(neg_unsigned_int, unsigned long long, unsigned long long)
01582
01583 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01584 PPL_SPECIALIZE_ADD(add_signed_int, char, char, char)
01585 #endif
01586 PPL_SPECIALIZE_ADD(add_signed_int, signed char, signed char, signed char)
01587 PPL_SPECIALIZE_ADD(add_signed_int, signed short, signed short, signed short)
01588 PPL_SPECIALIZE_ADD(add_signed_int, signed int, signed int, signed int)
01589 PPL_SPECIALIZE_ADD(add_signed_int, signed long, signed long, signed long)
01590 PPL_SPECIALIZE_ADD(add_signed_int, signed long long, signed long long, signed long long)
01591 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01592 PPL_SPECIALIZE_ADD(add_unsigned_int, char, char, char)
01593 #endif
01594 PPL_SPECIALIZE_ADD(add_unsigned_int, unsigned char, unsigned char, unsigned char)
01595 PPL_SPECIALIZE_ADD(add_unsigned_int, unsigned short, unsigned short, unsigned short)
01596 PPL_SPECIALIZE_ADD(add_unsigned_int, unsigned int, unsigned int, unsigned int)
01597 PPL_SPECIALIZE_ADD(add_unsigned_int, unsigned long, unsigned long, unsigned long)
01598 PPL_SPECIALIZE_ADD(add_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01599
01600 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01601 PPL_SPECIALIZE_SUB(sub_signed_int, char, char, char)
01602 #endif
01603 PPL_SPECIALIZE_SUB(sub_signed_int, signed char, signed char, signed char)
01604 PPL_SPECIALIZE_SUB(sub_signed_int, signed short, signed short, signed short)
01605 PPL_SPECIALIZE_SUB(sub_signed_int, signed int, signed int, signed int)
01606 PPL_SPECIALIZE_SUB(sub_signed_int, signed long, signed long, signed long)
01607 PPL_SPECIALIZE_SUB(sub_signed_int, signed long long, signed long long, signed long long)
01608 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01609 PPL_SPECIALIZE_SUB(sub_unsigned_int, char, char, char)
01610 #endif
01611 PPL_SPECIALIZE_SUB(sub_unsigned_int, unsigned char, unsigned char, unsigned char)
01612 PPL_SPECIALIZE_SUB(sub_unsigned_int, unsigned short, unsigned short, unsigned short)
01613 PPL_SPECIALIZE_SUB(sub_unsigned_int, unsigned int, unsigned int, unsigned int)
01614 PPL_SPECIALIZE_SUB(sub_unsigned_int, unsigned long, unsigned long, unsigned long)
01615 PPL_SPECIALIZE_SUB(sub_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01616
01617 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01618 PPL_SPECIALIZE_MUL(mul_signed_int, char, char, char)
01619 #endif
01620 PPL_SPECIALIZE_MUL(mul_signed_int, signed char, signed char, signed char)
01621 PPL_SPECIALIZE_MUL(mul_signed_int, signed short, signed short, signed short)
01622 PPL_SPECIALIZE_MUL(mul_signed_int, signed int, signed int, signed int)
01623 PPL_SPECIALIZE_MUL(mul_signed_int, signed long, signed long, signed long)
01624 PPL_SPECIALIZE_MUL(mul_signed_int, signed long long, signed long long, signed long long)
01625 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01626 PPL_SPECIALIZE_MUL(mul_unsigned_int, char, char, char)
01627 #endif
01628 PPL_SPECIALIZE_MUL(mul_unsigned_int, unsigned char, unsigned char, unsigned char)
01629 PPL_SPECIALIZE_MUL(mul_unsigned_int, unsigned short, unsigned short, unsigned short)
01630 PPL_SPECIALIZE_MUL(mul_unsigned_int, unsigned int, unsigned int, unsigned int)
01631 PPL_SPECIALIZE_MUL(mul_unsigned_int, unsigned long, unsigned long, unsigned long)
01632 PPL_SPECIALIZE_MUL(mul_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01633
01634 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01635 PPL_SPECIALIZE_DIV(div_signed_int, char, char, char)
01636 #endif
01637 PPL_SPECIALIZE_DIV(div_signed_int, signed char, signed char, signed char)
01638 PPL_SPECIALIZE_DIV(div_signed_int, signed short, signed short, signed short)
01639 PPL_SPECIALIZE_DIV(div_signed_int, signed int, signed int, signed int)
01640 PPL_SPECIALIZE_DIV(div_signed_int, signed long, signed long, signed long)
01641 PPL_SPECIALIZE_DIV(div_signed_int, signed long long, signed long long, signed long long)
01642 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01643 PPL_SPECIALIZE_DIV(div_unsigned_int, char, char, char)
01644 #endif
01645 PPL_SPECIALIZE_DIV(div_unsigned_int, unsigned char, unsigned char, unsigned char)
01646 PPL_SPECIALIZE_DIV(div_unsigned_int, unsigned short, unsigned short, unsigned short)
01647 PPL_SPECIALIZE_DIV(div_unsigned_int, unsigned int, unsigned int, unsigned int)
01648 PPL_SPECIALIZE_DIV(div_unsigned_int, unsigned long, unsigned long, unsigned long)
01649 PPL_SPECIALIZE_DIV(div_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01650
01651 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01652 PPL_SPECIALIZE_IDIV(idiv_signed_int, char, char, char)
01653 #endif
01654 PPL_SPECIALIZE_IDIV(idiv_signed_int, signed char, signed char, signed char)
01655 PPL_SPECIALIZE_IDIV(idiv_signed_int, signed short, signed short, signed short)
01656 PPL_SPECIALIZE_IDIV(idiv_signed_int, signed int, signed int, signed int)
01657 PPL_SPECIALIZE_IDIV(idiv_signed_int, signed long, signed long, signed long)
01658 PPL_SPECIALIZE_IDIV(idiv_signed_int, signed long long, signed long long, signed long long)
01659 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01660 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, char, char, char)
01661 #endif
01662 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, unsigned char, unsigned char, unsigned char)
01663 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, unsigned short, unsigned short, unsigned short)
01664 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, unsigned int, unsigned int, unsigned int)
01665 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, unsigned long, unsigned long, unsigned long)
01666 PPL_SPECIALIZE_IDIV(idiv_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01667
01668 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01669 PPL_SPECIALIZE_REM(rem_signed_int, char, char, char)
01670 #endif
01671 PPL_SPECIALIZE_REM(rem_signed_int, signed char, signed char, signed char)
01672 PPL_SPECIALIZE_REM(rem_signed_int, signed short, signed short, signed short)
01673 PPL_SPECIALIZE_REM(rem_signed_int, signed int, signed int, signed int)
01674 PPL_SPECIALIZE_REM(rem_signed_int, signed long, signed long, signed long)
01675 PPL_SPECIALIZE_REM(rem_signed_int, signed long long, signed long long, signed long long)
01676 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01677 PPL_SPECIALIZE_REM(rem_unsigned_int, char, char, char)
01678 #endif
01679 PPL_SPECIALIZE_REM(rem_unsigned_int, unsigned char, unsigned char, unsigned char)
01680 PPL_SPECIALIZE_REM(rem_unsigned_int, unsigned short, unsigned short, unsigned short)
01681 PPL_SPECIALIZE_REM(rem_unsigned_int, unsigned int, unsigned int, unsigned int)
01682 PPL_SPECIALIZE_REM(rem_unsigned_int, unsigned long, unsigned long, unsigned long)
01683 PPL_SPECIALIZE_REM(rem_unsigned_int, unsigned long long, unsigned long long, unsigned long long)
01684
01685 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01686 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, char, char)
01687 #endif
01688 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, signed char, signed char)
01689 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, signed short, signed short)
01690 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, signed int, signed int)
01691 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, signed long, signed long)
01692 PPL_SPECIALIZE_ADD_2EXP(add_2exp_signed_int, signed long long, signed long long)
01693 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01694 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, char, char)
01695 #endif
01696 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, unsigned char, unsigned char)
01697 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, unsigned short, unsigned short)
01698 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, unsigned int, unsigned int)
01699 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, unsigned long, unsigned long)
01700 PPL_SPECIALIZE_ADD_2EXP(add_2exp_unsigned_int, unsigned long long, unsigned long long)
01701
01702 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01703 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, char, char)
01704 #endif
01705 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, signed char, signed char)
01706 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, signed short, signed short)
01707 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, signed int, signed int)
01708 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, signed long, signed long)
01709 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_signed_int, signed long long, signed long long)
01710 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01711 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, char, char)
01712 #endif
01713 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, unsigned char, unsigned char)
01714 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, unsigned short, unsigned short)
01715 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, unsigned int, unsigned int)
01716 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, unsigned long, unsigned long)
01717 PPL_SPECIALIZE_SUB_2EXP(sub_2exp_unsigned_int, unsigned long long, unsigned long long)
01718
01719 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01720 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, char, char)
01721 #endif
01722 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, signed char, signed char)
01723 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, signed short, signed short)
01724 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, signed int, signed int)
01725 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, signed long, signed long)
01726 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_signed_int, signed long long, signed long long)
01727 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01728 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, char, char)
01729 #endif
01730 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, unsigned char, unsigned char)
01731 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, unsigned short, unsigned short)
01732 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, unsigned int, unsigned int)
01733 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, unsigned long, unsigned long)
01734 PPL_SPECIALIZE_MUL_2EXP(mul_2exp_unsigned_int, unsigned long long, unsigned long long)
01735
01736 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01737 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, char, char)
01738 #endif
01739 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, signed char, signed char)
01740 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, signed short, signed short)
01741 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, signed int, signed int)
01742 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, signed long, signed long)
01743 PPL_SPECIALIZE_DIV_2EXP(div_2exp_signed_int, signed long long, signed long long)
01744 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01745 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, char, char)
01746 #endif
01747 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, unsigned char, unsigned char)
01748 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, unsigned short, unsigned short)
01749 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, unsigned int, unsigned int)
01750 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, unsigned long, unsigned long)
01751 PPL_SPECIALIZE_DIV_2EXP(div_2exp_unsigned_int, unsigned long long, unsigned long long)
01752
01753 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01754 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, char, char)
01755 #endif
01756 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, signed char, signed char)
01757 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, signed short, signed short)
01758 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, signed int, signed int)
01759 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, signed long, signed long)
01760 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_signed_int, signed long long, signed long long)
01761 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01762 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, char, char)
01763 #endif
01764 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, unsigned char, unsigned char)
01765 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, unsigned short, unsigned short)
01766 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, unsigned int, unsigned int)
01767 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, unsigned long, unsigned long)
01768 PPL_SPECIALIZE_SMOD_2EXP(smod_2exp_unsigned_int, unsigned long long, unsigned long long)
01769
01770 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01771 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, char, char)
01772 #endif
01773 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, signed char, signed char)
01774 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, signed short, signed short)
01775 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, signed int, signed int)
01776 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, signed long, signed long)
01777 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_signed_int, signed long long, signed long long)
01778 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01779 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, char, char)
01780 #endif
01781 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, unsigned char, unsigned char)
01782 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, unsigned short, unsigned short)
01783 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, unsigned int, unsigned int)
01784 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, unsigned long, unsigned long)
01785 PPL_SPECIALIZE_UMOD_2EXP(umod_2exp_unsigned_int, unsigned long long, unsigned long long)
01786
01787 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01788 PPL_SPECIALIZE_SQRT(sqrt_signed_int, char, char)
01789 #endif
01790 PPL_SPECIALIZE_SQRT(sqrt_signed_int, signed char, signed char)
01791 PPL_SPECIALIZE_SQRT(sqrt_signed_int, signed short, signed short)
01792 PPL_SPECIALIZE_SQRT(sqrt_signed_int, signed int, signed int)
01793 PPL_SPECIALIZE_SQRT(sqrt_signed_int, signed long, signed long)
01794 PPL_SPECIALIZE_SQRT(sqrt_signed_int, signed long long, signed long long)
01795 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01796 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, char, char)
01797 #endif
01798 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, unsigned char, unsigned char)
01799 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, unsigned short, unsigned short)
01800 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, unsigned int, unsigned int)
01801 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, unsigned long, unsigned long)
01802 PPL_SPECIALIZE_SQRT(sqrt_unsigned_int, unsigned long long, unsigned long long)
01803
01804 #if PPL_CXX_PLAIN_CHAR_IS_SIGNED
01805 PPL_SPECIALIZE_ABS(abs_generic, char, char)
01806 #endif
01807 PPL_SPECIALIZE_ABS(abs_generic, signed char, signed char)
01808 PPL_SPECIALIZE_ABS(abs_generic, signed short, signed short)
01809 PPL_SPECIALIZE_ABS(abs_generic, signed int, signed int)
01810 PPL_SPECIALIZE_ABS(abs_generic, signed long, signed long)
01811 PPL_SPECIALIZE_ABS(abs_generic, signed long long, signed long long)
01812 #if !PPL_CXX_PLAIN_CHAR_IS_SIGNED
01813 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, char, char)
01814 #endif
01815 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, unsigned char, unsigned char)
01816 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, unsigned short, unsigned short)
01817 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, unsigned int, unsigned int)
01818 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, unsigned long, unsigned long)
01819 PPL_SPECIALIZE_ABS(assign_unsigned_int_unsigned_int, unsigned long long, unsigned long long)
01820
01821 PPL_SPECIALIZE_GCD(gcd_exact, char, char, char)
01822 PPL_SPECIALIZE_GCD(gcd_exact, signed char, signed char, signed char)
01823 PPL_SPECIALIZE_GCD(gcd_exact, signed short, signed short, signed short)
01824 PPL_SPECIALIZE_GCD(gcd_exact, signed int, signed int, signed int)
01825 PPL_SPECIALIZE_GCD(gcd_exact, signed long, signed long, signed long)
01826 PPL_SPECIALIZE_GCD(gcd_exact, signed long long, signed long long, signed long long)
01827 PPL_SPECIALIZE_GCD(gcd_exact, unsigned char, unsigned char, unsigned char)
01828 PPL_SPECIALIZE_GCD(gcd_exact, unsigned short, unsigned short, unsigned short)
01829 PPL_SPECIALIZE_GCD(gcd_exact, unsigned int, unsigned int, unsigned int)
01830 PPL_SPECIALIZE_GCD(gcd_exact, unsigned long, unsigned long, unsigned long)
01831 PPL_SPECIALIZE_GCD(gcd_exact, unsigned long long, unsigned long long, unsigned long long)
01832
01833 PPL_SPECIALIZE_GCDEXT(gcdext_exact, char, char, char, char, char)
01834 PPL_SPECIALIZE_GCDEXT(gcdext_exact, signed char, signed char, signed char, signed char, signed char)
01835 PPL_SPECIALIZE_GCDEXT(gcdext_exact, signed short, signed short, signed short, signed short, signed short)
01836 PPL_SPECIALIZE_GCDEXT(gcdext_exact, signed int, signed int, signed int, signed int, signed int)
01837 PPL_SPECIALIZE_GCDEXT(gcdext_exact, signed long, signed long, signed long, signed long, signed long)
01838 PPL_SPECIALIZE_GCDEXT(gcdext_exact, signed long long, signed long long, signed long long, signed long long, signed long long)
01839 PPL_SPECIALIZE_GCDEXT(gcdext_exact, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)
01840 PPL_SPECIALIZE_GCDEXT(gcdext_exact, unsigned short, unsigned short, unsigned short, unsigned short, unsigned short)
01841 PPL_SPECIALIZE_GCDEXT(gcdext_exact, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
01842 PPL_SPECIALIZE_GCDEXT(gcdext_exact, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
01843 PPL_SPECIALIZE_GCDEXT(gcdext_exact, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long)
01844
01845 PPL_SPECIALIZE_LCM(lcm_gcd_exact, char, char, char)
01846 PPL_SPECIALIZE_LCM(lcm_gcd_exact, signed char, signed char, signed char)
01847 PPL_SPECIALIZE_LCM(lcm_gcd_exact, signed short, signed short, signed short)
01848 PPL_SPECIALIZE_LCM(lcm_gcd_exact, signed int, signed int, signed int)
01849 PPL_SPECIALIZE_LCM(lcm_gcd_exact, signed long, signed long, signed long)
01850 PPL_SPECIALIZE_LCM(lcm_gcd_exact, signed long long, signed long long, signed long long)
01851 PPL_SPECIALIZE_LCM(lcm_gcd_exact, unsigned char, unsigned char, unsigned char)
01852 PPL_SPECIALIZE_LCM(lcm_gcd_exact, unsigned short, unsigned short, unsigned short)
01853 PPL_SPECIALIZE_LCM(lcm_gcd_exact, unsigned int, unsigned int, unsigned int)
01854 PPL_SPECIALIZE_LCM(lcm_gcd_exact, unsigned long, unsigned long, unsigned long)
01855 PPL_SPECIALIZE_LCM(lcm_gcd_exact, unsigned long long, unsigned long long, unsigned long long)
01856
01857 PPL_SPECIALIZE_SGN(sgn_generic, char)
01858 PPL_SPECIALIZE_SGN(sgn_generic, signed char)
01859 PPL_SPECIALIZE_SGN(sgn_generic, signed short)
01860 PPL_SPECIALIZE_SGN(sgn_generic, signed int)
01861 PPL_SPECIALIZE_SGN(sgn_generic, signed long)
01862 PPL_SPECIALIZE_SGN(sgn_generic, signed long long)
01863 PPL_SPECIALIZE_SGN(sgn_generic, unsigned char)
01864 PPL_SPECIALIZE_SGN(sgn_generic, unsigned short)
01865 PPL_SPECIALIZE_SGN(sgn_generic, unsigned int)
01866 PPL_SPECIALIZE_SGN(sgn_generic, unsigned long)
01867 PPL_SPECIALIZE_SGN(sgn_generic, unsigned long long)
01868
01869 PPL_SPECIALIZE_CMP(cmp_generic, char, char)
01870 PPL_SPECIALIZE_CMP(cmp_generic, signed char, signed char)
01871 PPL_SPECIALIZE_CMP(cmp_generic, signed short, signed short)
01872 PPL_SPECIALIZE_CMP(cmp_generic, signed int, signed int)
01873 PPL_SPECIALIZE_CMP(cmp_generic, signed long, signed long)
01874 PPL_SPECIALIZE_CMP(cmp_generic, signed long long, signed long long)
01875 PPL_SPECIALIZE_CMP(cmp_generic, unsigned char, unsigned char)
01876 PPL_SPECIALIZE_CMP(cmp_generic, unsigned short, unsigned short)
01877 PPL_SPECIALIZE_CMP(cmp_generic, unsigned int, unsigned int)
01878 PPL_SPECIALIZE_CMP(cmp_generic, unsigned long, unsigned long)
01879 PPL_SPECIALIZE_CMP(cmp_generic, unsigned long long, unsigned long long)
01880
01881 PPL_SPECIALIZE_ADD_MUL(add_mul_int, char, char, char)
01882 PPL_SPECIALIZE_ADD_MUL(add_mul_int, signed char, signed char, signed char)
01883 PPL_SPECIALIZE_ADD_MUL(add_mul_int, signed short, signed short, signed short)
01884 PPL_SPECIALIZE_ADD_MUL(add_mul_int, signed int, signed int, signed int)
01885 PPL_SPECIALIZE_ADD_MUL(add_mul_int, signed long, signed long, signed long)
01886 PPL_SPECIALIZE_ADD_MUL(add_mul_int, signed long long, signed long long, signed long long)
01887 PPL_SPECIALIZE_ADD_MUL(add_mul_int, unsigned char, unsigned char, unsigned char)
01888 PPL_SPECIALIZE_ADD_MUL(add_mul_int, unsigned short, unsigned short, unsigned short)
01889 PPL_SPECIALIZE_ADD_MUL(add_mul_int, unsigned int, unsigned int, unsigned int)
01890 PPL_SPECIALIZE_ADD_MUL(add_mul_int, unsigned long, unsigned long, unsigned long)
01891 PPL_SPECIALIZE_ADD_MUL(add_mul_int, unsigned long long, unsigned long long, unsigned long long)
01892
01893 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, char, char, char)
01894 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, signed char, signed char, signed char)
01895 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, signed short, signed short, signed short)
01896 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, signed int, signed int, signed int)
01897 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, signed long, signed long, signed long)
01898 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, signed long long, signed long long, signed long long)
01899 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, unsigned char, unsigned char, unsigned char)
01900 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, unsigned short, unsigned short, unsigned short)
01901 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, unsigned int, unsigned int, unsigned int)
01902 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, unsigned long, unsigned long, unsigned long)
01903 PPL_SPECIALIZE_SUB_MUL(sub_mul_int, unsigned long long, unsigned long long, unsigned long long)
01904
01905 PPL_SPECIALIZE_INPUT(input_generic, char)
01906 PPL_SPECIALIZE_INPUT(input_generic, signed char)
01907 PPL_SPECIALIZE_INPUT(input_generic, signed short)
01908 PPL_SPECIALIZE_INPUT(input_generic, signed int)
01909 PPL_SPECIALIZE_INPUT(input_generic, signed long)
01910 PPL_SPECIALIZE_INPUT(input_generic, signed long long)
01911 PPL_SPECIALIZE_INPUT(input_generic, unsigned char)
01912 PPL_SPECIALIZE_INPUT(input_generic, unsigned short)
01913 PPL_SPECIALIZE_INPUT(input_generic, unsigned int)
01914 PPL_SPECIALIZE_INPUT(input_generic, unsigned long)
01915 PPL_SPECIALIZE_INPUT(input_generic, unsigned long long)
01916
01917 PPL_SPECIALIZE_OUTPUT(output_char, char)
01918 PPL_SPECIALIZE_OUTPUT(output_char, signed char)
01919 PPL_SPECIALIZE_OUTPUT(output_int, signed short)
01920 PPL_SPECIALIZE_OUTPUT(output_int, signed int)
01921 PPL_SPECIALIZE_OUTPUT(output_int, signed long)
01922 PPL_SPECIALIZE_OUTPUT(output_int, signed long long)
01923 PPL_SPECIALIZE_OUTPUT(output_char, unsigned char)
01924 PPL_SPECIALIZE_OUTPUT(output_int, unsigned short)
01925 PPL_SPECIALIZE_OUTPUT(output_int, unsigned int)
01926 PPL_SPECIALIZE_OUTPUT(output_int, unsigned long)
01927 PPL_SPECIALIZE_OUTPUT(output_int, unsigned long long)
01928
01929 }
01930
01931 }
01932
01933 #endif // !defined(PPL_checked_int_inlines_hh)