I am using jean meeus's astronomical algorithm's formula :
int = whole number.
if (month > 2) leave month and year unchanged
if (month == 1 or month == 2) then year - 1 and month + 12
a = INT (year / 100)
b = 2 - a + INT ( a / 4)
Julian day = INT (365.25 * ( year + 4716)) + INT (30.6001 * ( month + 1 )) + day + b - 1524.5
For example, October 4.81, 1957;
or y = 1957 m = 10 d = 1957
because m > 2 we leave y and m unchanged
so
a = INT (1957 / 100) = INT (19.57) = 19
b = 2 - 19 + INT (19 / 4) = 2 - 19 + 4 = -13
jd = INT (365.25 * 6637) + INT (30.6001 * 11) + 4.81 - 13 - 1524.5
jd = 2436116.31
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::setprecision;
using std::endl;
/* GLOBAL VARIABLES */
double y = 1957;
double m = 10;
double d = 4.81;
double a;
double b;
double jd;
int main ()
{
if (m > 2) {
y = y;
m = m;
}
else if (m == 1 || m == 2) {
y--;
m+=12;
}
a = floor (y / 100.0);
b = 2 - a + floor (a / 4);
jd = floor (365.25 * (y + 4716)) + floor (30.001 * ( m + 1)) + d + b - 1524.5;
cout << setprecision (16) << jd << endl;
cin.get();
return 0;
}
|
So why is my output:
it should really be:
as posted above
I did this right. I obtained a copy of the book that this source is in and
I double checked it more than once and I did it right.