/*
 * $Id: misc.c,v 2.4 91/02/22 21:22:23 tynor Exp $
 *----------------------------------------------------------------------------
 *	FPLAN - Flight Planner
 *	Steve Tynor
 *	tynor@prism.gatech.edu
 *
 *	This program is in the public domain. Permission to copy,
 * distribute, modify this program is hearby given as long as this header
 * remains. If you redistribute this program after modifying it, please
 * document your changes so that I do not take the blame (or credit) for
 * those changes.  If you fix bugs or add features, please send me a
 * patch so that I can keep the 'official' version up-to-date.
 *
 *	Bug reports are welcome and I'll make an attempt to fix those
 * that are reported.
 *
 *	USE AT YOUR OWN RISK! I assume no responsibility for any
 * errors in this program, its database or documentation. I will make an
 * effort to fix bugs, but if you crash and burn because, for example,
 * fuel estimates in this program were inaccurate, it's your own fault
 * for trusting somebody else's code! Remember, as PIC, it's _your_
 * responsibility to do complete preflight planning. Use this program as
 * a flight planning aid, but verify its results before using them.
 *----------------------------------------------------------------------------
 */

static char rcsid[] = "$Id: misc.c,v 2.4 91/02/22 21:22:23 tynor Exp $";

#include <math.h>

/*----------------------------------------------------------------------------*/
double degrees_mins_2_decimal (hm)
     double hm;
{
   /*
    * input looks like: 40.45 (40 deg, 45 min), output is 40.75 (40.75 deg)
    */
   double i = (double) aint (hm);
   
   return (i + (hm - i) / 0.6);
}

/*----------------------------------------------------------------------------*/
double decimal_2_degrees_mins (dec)
     double dec;
{
   /*
    * input looks like: 40.75 (40.75 deg), output is 40 and 45 (40 deg, 45 min)
    */
   double tmp = (double) aint (dec);

   return (tmp + 0.6 * (dec - tmp));
}

