Hi
>Note also that the code is not 64-bit portable, see http://www.boyd.com/1364_btf/report/full_pr/220.html.
>
>
>
OK, here's my little test.
#include <iostream>
#include <climits>
#include <cmath>
#include <cstdlib>
using namespace std;
double ieee_1364_uniform(long *seed, double start, double end)
{
...
}
double ieee_1364_uniform_ll(long long *seed, double start, double end)
{
...
}
int main()
{
long seed = 3L;
long long lseed = 3LL;
double res, lres;
for (int i = 0; i < 1000000; ++i)
{
res = ieee_1364_uniform(&seed, -1000000, 1000000);
lres = ieee_1364_uniform_ll(&lseed, -1000000, 1000000);
if (res != lres)
{
cerr << "results mismatch, res " << res << " lres " << lres << "\n";
}
if ((long long)seed != lseed)
{
cerr << "seeds mismatch, seed " << seed << " lseed " << lseed <<
"\n";
}
}
}
For brevity I've omitted the function bodies; they are unchanged except
that for the error condition I changed it to a cerr and exit.
The important change is to the signature, using long and long long to be
able to compare 64bit and 32bit on the same machine.
I see no difference between res and lres; seed and lseed differ unless
lseed is truncated to 32bits (e.g, with a cast or just by storing it in
an int).
Regards
Paul Floyd
-- Dr Paul Floyd Mentor Graphics Corporation -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon Jun 6 03:14:38 2011
This archive was generated by hypermail 2.1.8 : Mon Jun 06 2011 - 03:14:51 PDT