How to deal with large numbers in the PROP? Calculating Julian Day
tosjduenfs
Posts: 37
I'm working on a program that converts Right Ascension and Declination coordinates to Altitude and Azimuth coordinates for use in an auto tracking telescope. As my calculations go on the results get necessarily larger and larger. I'm stuck now calculating days since Julian Date J2000. When I figure the number on my calculator I get 2456577.51006944 days but when I run the calcs on the prop I get 2456578. The decimal portion is very import to further calculations. I realize I'm probably running in to the limit of 32bit precision, is there a way to overcome these issues?
If someone could tell me how to add a code block in my post I will post my code.
Thanks
Mike
If someone could tell me how to add a code block in my post I will post my code.
Thanks
Mike
Comments
-Phil
If you search the forum for Julian Date, I think you'll find some recent discussion on this issue.
There's a link to Rich's forum search engine at the top of post #1 of my index (see my signature for link).
You may need to use floating point numbers in your calculations. I'm sure I have a link to the F32 thread (a better faster floating point object) in my index IIRC, it's in post #5 (but I'm not sure).
There's a link to a tutorial on how to post code in the forum in post #3 of my index.
http://obex.parallax.com/object/551
Also see its thread...
http://forums.parallax.com/showthread.php/136178-Solar-Tracking-Object
I've written ordinal time methods for real time data logging, all integer math.
In the end what I really need is Greenwich Mean Sidereal Time or my Local Hour Angle. The only way I know how to get GMST or LHA is a calculation starting with Julian days or seconds.
Tracy, I'm sorry if this is an ignorant question but I've only really starting learning about Julian dates, sidereal time etc very recently. I'm not exactly sure how your code works. I see that you calculate seconds from midnight Jan. 1, 2001 but shouldn't a Julian date be calculated from J2000 or Noon Jan. 1, 2000? I realize it would be trivial to find the difference between the two dates but even if you do calculate from midnight 2001 rather than noon 2000 I don't see how you can get less than 212 billion seconds.
-Phil
I use ordinal time in my programs as a means to start data logging at a certain date/time, for a certain interval, and to stop at another date/time. Ordinal time avoids the complications that come from the odd number system of transitioning from day to day, month to month, year to year. The starting point does not matter. It could be like the PC starting in 1900, or the Mac in 1904, or Unix epoch 1970. I think I started mine in 2001 because I wrote my first version of it for the BASIC Stamp in 2001 and needed only to keep track of future time. I really shouldn't call it julian day number. It is just a scheme of ordinal time that can be converted to other schemes by addition of a constant.
Correct me if I'm wrong here, but for the astronomer, julian day #1 started at noon on January 1, 4713 BC. In that system, the new year's party on Jan 1 2001 occurred at julian day number 2451910.5. Multiplying that by the number of seconds in a day does in fact exceed 32 bits by a long shot. However, it does fit easily into 63 bits, 19- decimal digits. Phil made an object, "Umath" that contains various 64 bit integer methods. AFAIK, there is no 64 bit floating point for the Prop. A few threads have popped up here about sidereal time calculations, but I'm out of my element, not much help. Maybe you can deal with the integer and fractional parts separately?
Thank you guys for your help in pushing me in the right direction my calculations are coming out much better now.
One advantage is that you could test the math on a PC and then use the exact same code on the Prop...
tosjduenfs
Your problem and these posts acted as some kind of wayback machine has catched me up, in a time travel till early 70's.
It was one of the first programs I'd coded, to calculate days between dates; kind of bond trading machine, for a banking institution.
Good times, good remembrances. Thank you for posting this.
Perhaps the following link can add a bit of understanding to the whole problem, including concerns about correct mathematical representation of values and scales.
There you'll also find a Julian Date Converter, to check your values and assumptions.
http://aa.usno.navy.mil/data/docs/JulianDate.php
I hope it can help you a bit
Yanomani