2 * deg - calculate in degrees, minutes, and seconds
4 * Copyright (C) 1999 David I. Bell
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.2 $
21 * @(#) $Id: deg.cal,v 30.2 2010/09/02 06:01:14 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/cal/RCS/deg.cal,v $
24 * Under source code control: 1990/02/15 01:50:33
25 * File existed as early as: before 1990
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 obj deg {deg, min, sec};
33 define deg(deg, min, sec)
95 if (istype(a, ans) && istype(b, ans))
96 quit "Cannot multiply degrees together";
113 print a.deg : 'd' : a.min : 'm' : a.sec : 's' :;
119 return a.deg + a.min / 60 + a.sec / 3600;
125 a.min += frac(a.deg) * 60;
127 a.sec += frac(a.min) * 60;
129 a.min += a.sec // 60;
131 a.deg += a.min // 60;
136 if (config("resource_debug") & 3) {
137 print "obj deg {deg, min, sec} defined";