Floor function returning EXC_BAD_ACCESS

Posted by fastrack20 on Stack Overflow See other posts from Stack Overflow or by fastrack20
Published on 2010-05-27T18:39:22Z Indexed on 2010/05/28 14:21 UTC
Read the original article Hit count: 344

Filed under:
|

The cod that I am using contains these snippets of code. I am calling ThetaG_JD with the argument 2455343.50000 which is just a sample Julian date. Every time I run the program, I receive a EXC_BAD_ACCESS on the indicated line. When using gdb and printing out the intermediary values and passing them through the floor function, I get no error, but when Frac() is used it always returns an error.

double Frac(double arg)
{
    /* Returns fractional part of double argument */
    return arg - floor(arg);
}

double ThetaG_JD(double jd)
{
    /* Reference:  The 1992 Astronomical Almanac, page B6. */

    double UT=0, TU=0, GMST=0;
    //THIS LINE
    UT=Frac(jd+0.5);
    // THAT ONE ^^
    jd=jd-UT;
    TU=(jd-2451545.0)/36525;
    GMST=24110.54841+TU*(8640184.812866+TU*(0.093104-TU*6.2E-6));
    GMST=Modulus(GMST+secday*omega_E*UT,secday);

    return (twopi*GMST/secday);
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about floor