This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

julian day function hosed

I can't get my julian day function working. With gcc and msvc++ it works perfectly. In the Keil compiler it doesn't. The date 05/21/2003 should produce 2452781 julian days, instead it produces 27950. And sometimes the month parameter is hosed. It's supposed to be 5, but a lot of the times it's like 31713 or some crazy value.

Program Size: data=127.3 xdata=8174 code=36284

// Julian day number 0 corresponds to -4713-11-24 Gregorian. The
// Julian day (jd) is computed from Gregorian day, month and year (d,
// m, y) as follows:
ULONG julian(int month, int day, int year)
{
  return ( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 +
       ( 367 * ( m - 2 - 12 * ( ( m - 14 ) / 12 ) ) ) / 12 -
       ( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 +
       d - 32075;
}