int main()
{
#if 0
- unsigned buf[5] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0 };
+ unsigned long buf[5] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0 };
//unsigned buf[3] = { 0xffffffff, 0x1, 0 };
number<> nu(buf, 4);
//number< unsigned > nu2(nu);
std::cout << "nu2 = " << nu2 << "\n\n";
std::cout << "nu + nu2 = " << nu + nu2 << "\n\n";
std::cout << "nu * nu2 = " << nu * nu2 << "\n\n";
+ std::cout << "nu^nu2 = " << potencia(nu, nu2) << "\n\n";
#endif
#if 0
number< unsigned > nu = 0xffffffff;
- std::cout << "nu = " << nu << "\n\n";
+ std::cout << "nu = " << nu ;
nu << 5;
- std::cout << "nu = " << nu << "\n\n";
-#endif
-\r
- number<> n1 = 0x00000000;
- number<> n2 = 0x00000000;
+ std::cout << "nu = " << nu ;
+
+ number<> n1 = 0xFFFFFFFF;
+ number<> n2 = 0xFFFFFFFF;
- n2 += 1;
+ n1 += 1;
- n1 <<= 1;
- n2 <<= 1;
+/* for (int k = 0; k < 100; k++)
+ {
+ n1 += (unsigned) rand() * k;
+ n2 += (unsigned) rand() * k;
+ }
+*/
+
+// n1 <<= 1;
+// n2 <<= 1;
if (n1 < n2)
std::cout << "n1 es menor que n2\n";
else if (n2 < n1)
- std::cout << "n1 es mayor que n2\n";\r
+ std::cout << "n1 es mayor que n2\n";
else
- std::cout << "n1 es igual que n2\n";\r
-\r
- std::cout << "\n";
- \r
-\r
-// for (int j=0; j<10; j++)\r
-// n1.borrow(0);\r
-\r
- std::cout << "n1: " << n1 ;\r
- std::cout << "\n";\r
- std::cout << "n2: " << n2 ;\r
- std::cout << "\n";\r
-\r
- n1 -= n2;\r
-\r
- std::cout << "n1-n2: " << n1 ;\r
+ std::cout << "n1 es igual que n2\n";
- return 0;
+ std::cout << "\n";
+
+// for (int j=0; j<10; j++)
+// n1.borrow(0);
+
+ std::cout << "n1: " << n1 ;
+ std::cout << "\n";
+ std::cout << "n2: " << n2 ;
+ std::cout << "\n";
+
+ n1 -= n2;
+
+ std::cout << "n1-n2: " << n1 ;
+#endif
+
+#if 1
+ uint32_t buf[] = { 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
+ number<> nu(buf, 8, negative);
+ number<> nu2 = 0x2;
+ std::cout << "nu = " << nu ;
+ std::cout << "\n";
+ std::cout << "nu2 = " << nu2 ;
+ std::cout << "\n";
+ std::cout << "nu * nu2 = " << naif(nu, nu2) ;
+ std::cout << "\n";
+ std::cout << "nu + nu2 = " << nu + nu2 ;
+ std::cout << "\n";
+ std::cout << "nu - nu2 = " << nu - nu2 ;
+
+#endif
+
+ number<> h = 0x10000000;
+ h<<=1;
+ h += 0xfffffffc;
+ h<<=1;
+ h += 0xffffffff;
+ h<<=1;
+ h += 0x00000002;
+ number<> d = 0;
+ number<> m = 0xfffffffe;
+ m<<=1;
+ m += 0xffffffff;
+ m<<=1;
+ m += 0x00000001;
+
+ std::cout << "h: " << h ;
+ std::cout << "\n";
+ std::cout << "d: " << d ;
+ std::cout << "\n";
+ std::cout << "m: " << m ;
+ std::cout << "\n";
+
+ number<> a = h - d - m;
+
+ std::cout << "h-d-m: " << a ;
+
+
+ return 0;
}