fixed stuff in uint_inf_bits that was dumb sizeof returns bytes added pop and Rshift...
[infINT.git] / extraFunc.cpp
1 #include <iostream>\r
2 #include <stdio.h>\r
3 #include <mmintrin.h>\r
4 #include <intrin.h>\r
5 \r
6 #pragma intrinsic(_umul128)\r
7 namespace eFunc\r
8 {\r
9     bool addOvf(uint_fast64_t &a,const uint_fast64_t &b)  { \r
10         bool ret = (a > ~b);\r
11         a+=b;\r
12         return ret;\r
13     }\r
14     bool addOvf(const uint_fast64_t &a,const uint_fast64_t &b,uint_fast64_t &sum)  { \r
15         bool ret = (a > ~b);\r
16         sum = a + b;\r
17         return ret;\r
18     }\r
19     bool subUnf(uint_fast64_t &a,const uint_fast64_t &b)  { \r
20         bool ret = (a > b);\r
21         a -= b;\r
22         return ret;\r
23     }\r
24     bool subUnf(const uint_fast64_t &a,const uint_fast64_t &b,uint_fast64_t &dif)  { \r
25         bool ret = (a > b);\r
26         dif = a - b;\r
27         return ret;\r
28     }\r
29     uint_fast64_t mul128(const uint_fast64_t &Multiplicand, const uint_fast64_t &Multiplier,uint_fast64_t &HighProduct)  {  \r
30         return _umul128(Multiplier, Multiplicand, &HighProduct);\r
31     }\r
32     uint_fast64_t div_rq(const uint_fast64_t &Dividend, const uint_fast64_t &Divisor,uint_fast64_t &Quotient)  {  \r
33         Quotient = Dividend/Divisor;\r
34         return Dividend%Divisor;\r
35     }\r
36     uint_fast64_t div_qr(const uint_fast64_t &Dividend, const uint_fast64_t &Divisor,uint_fast64_t &Remainder)  {\r
37         Remainder = Dividend%Divisor;\r
38         return Dividend/Divisor;\r
39     }\r
40     template <class Type>\r
41     Type mul_bits(const Type &Multiplicand, const Type &Multiplier,Type &HighProduct)  {  \r
42         return _umul128(Multiplier, Multiplicand, &HighProduct);\r
43     }\r
44     class newTypes {\r
45 \r
46     };\r
47 \r
48 }
This page took 0.029818 seconds and 4 git commands to generate.