|
From: Alfred P. R. <al...@ya...> - 2005-05-01 00:06:21
|
Hi Noorez,
Is there such a thing as an unsigned double? IMHO, floats and doubles are always signed.
There's also a switch for 12 byte and 16 byte long doubles, if that helps. Try GCC --target-help.
I compiled and ran your program as a new project using the File-->New-->Project...-->Console Application feature, just deleting the keyword unsigned, adding a line for clarity at the top to show that something is going on, and a precision of 15 decimal digits to the output statement. iomanip contains the definitions to setprecision().
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
const double numerator = 4;
double PI = 4; // short, signed or unsigned invalid for PI.
bool add = false;
cout << "Running..." << endl;
for(double i = 3; i < 999999999; i+=2)
{
if( add )
{
PI += numerator/i;
add = false;
}
else
{
PI -= numerator/i;
add = true;
}
}
cout << setprecision(15) << PI << endl << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
It worked fine!
Noorez Kassam <dar...@ho...> wrote:
trying to make something to calculate PI to a large place value. The compile
error is on the marked line
#include
#include
using namespace std;
int main()
{
const double numerator = 4;
unsigned double PI = 4; // short, signed or unsigned invalid for `PI'
bool add = false;
for(double i = 3; i < 999999999; i+=2)
{
if( add )
{
PI += numerator/i;
add = false;
}
else
{
PI -= numerator/i;
add = true;
}
}
cout << PI << endl << endl;
system("pause");
}
_________________________________________________________________
Don't just Search. Find! http://search.sympatico.msn.ca/default.aspx The new
MSN Search! Check it out!
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
Alfred P. Reaud
|