ok, call me stupid, maybe i forgot my math:

but if a C++ program spits out this:

-bash-2.05b$ g++ markoff.cpp
-bash-2.05b$ ./a.out
x = 1 y = 1 z = 2
x = 1 y = 2 z = 5
x = 2 y = 5 z = 29
x = 5 y = 29 z = 433
x = 29 y = 433 z = 37666
x = 433 y = 37666 z = 4.89281e+07

what is the number? 4.89281e+07 ???

is it like scientific notation (4.89281 x 10^7) ??

oh ok...so 4.89281e+07 is 48,928,100 ?

thanks

>oh ok...so 4.89281e+07 is 48,928,100 ?
Well, it takes a bit of work to do the commas, but let's see:

#include <iostream>
#include <locale>
#include <string>

using namespace std;

class numfmt: public numpunct<char> {
  string do_grouping() const { return "\3"; }
  char_type do_thousands_sep() const { return ','; }
};

int main()
{
  cout.imbue ( locale ( locale(), new numfmt ) );
  cout<< fixed << 4.89281e+07 <<endl;
}

Yep, sure seems that way. ;)

hmmm, never seen that code

cuz i was just about to ask how can i get it to be more precise?

so far my code:

#include <iostream>
#include <math.h>
using namespace std;

double xyz[3];
double mark[3];

void markoff(double x, double y, double z)
{
  mark[0] = y;
  mark[1] = z;
  mark[2] = ((3*y*z) - x);

  cout<<"x = "<<mark[0]<<" y = "<<mark[1]<<" z = "<<mark[2]<<endl;
}

int main()
{

  xyz[0] = 1;
  xyz[1] = 1;
  xyz[2] = 1;

  while( mark[2] < (pow(10.0,101.0)) )
    {
      markoff( xyz[0], xyz[1], xyz[2] );

      xyz[0] = mark[0];
      xyz[1] = mark[1];
      xyz[2] = mark[2];
    }


  return 0;
}


output:

-bash-2.05b$ ./a.out
x = 1 y = 1 z = 2
x = 1 y = 2 z = 5
x = 2 y = 5 z = 29
x = 5 y = 29 z = 433
x = 29 y = 433 z = 37666
x = 433 y = 37666 z = 4.89281e+07
x = 37666 y = 4.89281e+07 z = 5.52878e+12
x = 4.89281e+07 y = 5.52878e+12 z = 8.11538e+20
x = 5.52878e+12 y = 8.11538e+20 z = 1.34604e+34
x = 8.11538e+20 y = 1.34604e+34 z = 3.2771e+55
x = 1.34604e+34 y = 3.2771e+55 z = 1.32333e+90
x = 3.2771e+55 y = 1.32333e+90 z = 1.30101e+146

well, i get a whole bunch of those numbers, but no precision ...

grrrrrr .... and this isnt even for a CS class (discrete math 2)

Well, if you want to force precision, add the blue line:

#include <iostream>
#include <math.h>
using namespace std;

double xyz[3];
double mark[3];

void markoff(double x, double y, double z)
{
  mark[0] = y;
  mark[1] = z;
  mark[2] = ((3*y*z) - x);

  cout<<"x = "<<mark[0]<<" y = "<<mark[1]<<" z = "<<mark[2]<<endl;
}

int main()
{

  xyz[0] = 1;
  xyz[1] = 1;
  xyz[2] = 1;

  cout.setf ( ios::fixed, ios::floatfield );
  while( mark[2] < (pow(10.0,101.0)) )
    {
      markoff( xyz[0], xyz[1], xyz[2] );

      xyz[0] = mark[0];
      xyz[1] = mark[1];
      xyz[2] = mark[2];
    }

  return 0;
}

But you'll probably just get a ton of zeros instead of anything useful.

actually, it printed it out just fine ....

and after all this, i didnt really even need it, as i needed to just count the times ...... well, blah ... oh well, at least i learned something .... kinda

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.