Hello,
I'm trying to do calculate Local Sidereal Time with precision for a project
for the function below the arguments are
DDMMYY is the date as an integer
Time is calculated with formula (SS/3600 + MM/60 + HH)*1000000
long LMST(int DDMMYY, long Time)
{
byte YY = DDMMYY % 100;
byte MM = (DDMMYY % 10000) / 100;
byte DD = DDMMYY / 100;
if(MM < 2)//YY & MM correction
{
MM +=12;
YY -=1;
}
//Julian Day =INT(365,25*(YEAR+4716))+INT(30,6001*(MONTH+1))+Day-13-1524,5+UTC_As_Long
//MJD = Julian Day - 2400000.5
uint64_t MJD = (365250000 * (YY + 6716)) + (30600100 * (MM+1)) - 2400000500000;
//MJD0 = integer part of MJD
unsigned long MJD0 = MJD / 1000000L;
//UT = (MJD - MJD0)*24
unsigned long UT = (MJD - MJD0) * 24;
//T_EPH = (MJD0-51544.5)/36525.0
unsigned long T_EPH = (MJD0 - 5144500000)/36525000000;
//GMST = 6,697374558+1,0027379093*ut+(8640184,812866+(0,093104-0,0000062*t_eph)*t_eph)*t_eph/3600
uint64_t GMST = 6697374 + 1002737 * UT + (8640184812866 + (93104 - 6 * T_EPH) * T_EPH) * T_EPH/3600;
//Frac=(GMST + longitude/15.0)/24.0
unsigned long Frac = (GMST + Lng/15)/24;
//LMST=24*Frac
return 24 * Frac;
}
When i try to compile i get the error " error: integer constant is too large for 'long' type"
at uint64_t MJD = ...
Any advice on how to solve the proble and maybe how to improve the function?
Thank you