[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug report
From: |
GAMMELJL |
Subject: |
bug report |
Date: |
Mon, 19 Mar 2001 13:48:29 -0600 (CST) |
//Here, as simply as I can put it, is a bug (?) having to do with
//trying to set an mpf_t (which is a member of a class) inside a
//subroutine: The notes are contained in cout statements (so that
//the notes will appear on the screen if the code below is compiled
//and run).
//If you do not wish to compile and run the code below, start
//reading cout at POINT1 below, then from POINT2 to POINT3, and
//finally at POINT4 to the end.
//Data you asked for: version: gmp-3.1
// compiler: g++
// compiled with: g++ code.cpp -o code -lgmp
// output of uname -a:
//localhost.localdomain 2.0.35 #1 Tue July 14 23:56:59 EDT 1998
// i 686 unknown
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "gmp.h"
#include "gmp-impl.h"
class realmp{
public:
mpf_t s;
realmp();
};
realmp::realmp()
{mpf_init2(s,1695);
mpf_set_si(s,-777);}
realmp a;
void zfcn(realmp ww8)
{cout<<"a.s in zfcn before ww8.s is set "; mpf_dump(a.s);//POINT2
cout<<"which is what it was set to in realmp() when"<<'\n';
cout<<"a was declared, and that is correct."<<'\n';
cout<<"ww8.s in zfcn before ww8.s is set ";mpf_dump(a.s);
cout<<"which is likewise correct."<<'\n';
cout<<"Now set ww8.s to 88:"<<'\n';
mpf_set_si(ww8.s,88);
cout<<"Notice that ww8.s is set correctly in zfcn: ";
mpf_dump(ww8.s);
cout<<"But, a.s in zfcn after ww8.s is set,"<<'\n';
cout<<"ought to be the same thing as ww8.s, which it is"<<'\n';
cout<<"except it has the wrong sign: "; //POINT3
mpf_dump(a.s);
}
main()
{cout<<'\n';
cout<<"Try to set a.s to 88 using zfcn:"<<'\n'; //POINT1
zfcn(a);
cout<<"and this wrong sign is returned to main: "<<'\n';//POINT4
mpf_dump(a.s);
cout<<'\n';
cout<<"The bug (?) is: what happened to the sign?"<<'\n';
cout<<'\n';
cout<<"Change the -777 to +777 and the sign will come"<<'\n';
cout<<"out ok, but that begs the question. Change the"<<'\n';
cout<<"-777 to 0 and the result will be 0. "<<'\n';
cout<<'\n';
return 0;
}