[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
strange results with 'power' operator in c++
From: |
Pierre Colombier |
Subject: |
strange results with 'power' operator in c++ |
Date: |
Mon, 16 Jan 2006 23:03:09 -0000 |
User-agent: |
Mozilla Thunderbird 1.0.7 (Windows/20050923) |
this is my test file "main.cc"
#include <iostream>
using namespace std;
#include <gmpxx.h>
int main (void)
{
mpz_class x, p, q, eq, ep;
x=2;
p=0;
q=0;
ep=19;
eq=27;
cout << "X=" <<x <<"\n";
cout << "P=" << p << "\n";
cout << "Q=" << q << "\n";
cout << "EP=" << ep << "\n";
cout << "EQ=" << eq << "\n";
p=x^ep;
q=x^eq;
cout << "----\n";
cout << "P=" << p << "\n";
cout << "Q=" << q << "\n";
return 0;
}
it produces :
# g++ main.cc -lgmpxx -lgmp -Wall
# ./a.out
X=2
P=0
Q=0
EP=19
EQ=27
----
P=17
Q=25
#
why P=17 and Q=25 ???
should be P=524288 and Q=2097152
(operations + - * / % works well is there a problem with ^ )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- strange results with 'power' operator in c++,
Pierre Colombier <=