c++ - Is a double not big enough to hold my data? -


i writing program simulate gps system. hard-coded in data debug in visual studio. running program in terminal can pipe in data. problem in do-while loop. trying iterate time until condition "check>0.01c" satisfied, c speed of light. position , time of satellite, xs , ts, respectively, intertwined. continually recalculating xs new, more accurate value of t. second time through, tnew not change. first time, reason can come doesn't change small it's insignificant. great, i've been debugging hours on end. included code surrounding do-while loop think problem:

#include<iostream> #include<fstream> #include<sstream> #include<string> #include<iomanip> #include<math.h> #include<cmath> using namespace std;  int main() {         // go through each satellite , calculate ts , xs         (int = 0; is<24; is++)         {             // compute ts , xs             double initialxs[3];             (int kk = 0; kk<3; kk++)             {                 initialxs[kk] = (r + h)*(u[is][kk] * cos(((2.0 * pi*tv) / (s / 2.0)) + ph[is][0]) + v[is][kk] * sin(((2.0 * pi*tv) / (s / 2.0)) + ph[is][0]));             }             double told = tv;             double tnew = tv - (sqrt((initialxs[0] - xv[0])*(initialxs[0] - xv[0]) + (initialxs[1] - xv[1])*(initialxs[1] - xv[1]) + (initialxs[2] - xv[2])*(initialxs[2] - xv[2]))) / c;             double check = abs(tnew - told);             double xs[3];             {                 told = tnew;                 (int ii = 0; ii < 3; ii++)                 {                     xs[ii] = (r + h)*(u[is][ii] * cos(2 * pi*told / (s / 2) + ph[is][0]) + v[is][ii] * sin(2 * pi*told / (s / 2) + ph[is][0]));                 }                 tnew = tv - (sqrt((xs[0] - xv[0])*(xs[0] - xv[0]) + (xs[1] - xv[1])*(xs[1] - xv[1]) + (xs[2] - xv[2])*(xs[2] - xv[2]))) / c;                 check = abs(tnew - told);                 cout << check << endl;             } while (check > (0.01 / c));           double ts = tnew;       return 0; } 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -