mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Added more builtin inverse conversion functions
Added builtin functions to convert between degrees, minutes and seconds and degrees under the config("mod") round rules: dms2d(d, m, s [,rnd]) - convert deg, min, and secs to deg dm2d(d, m [,rnd]) - convert deg, min to deg See help/dms2d and help/dm2d. Example: ; print dms2d(12, 20, 44.16); 12.3456 ; print dm2d(3601, -25.5594); 0.57401 Added builtin functions to convert between gradians, minutes and seconds and gradians under the config("mod") round rules: gms2g(g, m, s [,rnd]) - convert grad, min, and secs to grad gm2g(g, m [,rnd]) - convert grad and min to grad See help/g2gms and help/g2gm. Example: ; print gms2g(12, 20, 44.16); 12.3456 ; print gm2g(4001, -25.5594); 0.57401 Added builtin functions to convert between hours, minutes and seconds and hours under the config("mod") round rules: hms2h(h, m, s [,rnd]) - convert hours, min, and secs to hours hm2h(h, m [,rnd]) - convert hours, min to hours See help/hms2h and help/hm2h. Example: ; print hms2h(12, 20, 44.16); 12.3456 ; print hm2h(241, -25.5594); 0.57401
This commit is contained in:
@@ -365,17 +365,17 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
||||
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
|
||||
d2dms d2g d2r delete den dereference det digit digits display dp \
|
||||
d2dms d2g d2r delete den dereference det digit digits display dms2d dp \
|
||||
epsilon errcount errmax errno error estr euler eval exp fact factor \
|
||||
fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
|
||||
fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
|
||||
fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||
freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
|
||||
g2r gcd gcdrem gd getenv h2hm h2hms hash head highbit hmean hnrmod \
|
||||
hypot ilog ilog10 ilog2 im indices inputlevel insert int inverse iroot \
|
||||
isalnum isalpha isassoc isatty isblk iscntrl isconfig isdefined \
|
||||
isdigit iserror iseven isfile isgraph ishash isident isint islist \
|
||||
islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
|
||||
g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \
|
||||
hms2h hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
|
||||
inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \
|
||||
isdefined isdigit iserror iseven isfile isgraph ishash isident isint \
|
||||
islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
|
||||
isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
|
||||
isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
|
||||
lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
|
||||
|
@@ -76,7 +76,7 @@ EXAMPLE
|
||||
; global d, m, s;
|
||||
|
||||
; print d2dms(12.3456,d,m,s), d, m, s;
|
||||
12.3456, 12, 20, 44.16
|
||||
12.3456 12 20 44.16
|
||||
; print d2dms(1234.5678,d,m,s), d, m, s;
|
||||
154.5678 154 34 4.08
|
||||
; print d2dms(-1234.5678,d,m,s), d, m, s;
|
||||
|
84
help/dms2d
Normal file
84
help/dms2d
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
dm2d, dms2d - convert degrees, minutes, and seconds to degrees
|
||||
|
||||
SYNOPSIS
|
||||
dm2d(d, m [,rnd])
|
||||
dms2d(d, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
d real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return degrees
|
||||
|
||||
DESCRIPTION
|
||||
Convert degrees, m minutes, and s seconds returning degrees.
|
||||
|
||||
The return value in degrees, is quivalent to the following:
|
||||
|
||||
mod(d + m/60 + s/3600, 360, rnd);
|
||||
|
||||
Depending on the rounding mode, the return could be a real value
|
||||
in the interval [0, 360) or a real value in the interval (-360, 0].
|
||||
For the default round mode, the return value is in the interval [0, 360).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The dm2d(d, m, rnd) builtin is an alias for dms2d(d, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print dm2d(203, 325.5594);
|
||||
208.42599
|
||||
; print dm2d(3601, -25.5594);
|
||||
0.57401
|
||||
; print dm2d(-923, -25.5594);
|
||||
156.57401
|
||||
|
||||
; print dms2d(12, 20, 44.16);
|
||||
12.3456
|
||||
; print dms2d(123.456, -345.68, 4.08);
|
||||
117.6958
|
||||
; print dms2d(-65, -40, -44.4);
|
||||
294.321
|
||||
|
||||
; print dm2d(203, 325.5594, 1);
|
||||
-151.57401
|
||||
; print dms2d(12, 20, 44.16, 1);
|
||||
-347.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
|
||||
h2hm, h2hms, hm2d, hms2d, mod
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/25 17:24:51
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
84
help/gms2g
Normal file
84
help/gms2g
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
gm2g, gms2g - convert gradians, minutes, and seconds to gradians
|
||||
|
||||
SYNOPSIS
|
||||
gm2g(d, m [,rnd])
|
||||
gms2g(d, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
d real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return gradians
|
||||
|
||||
DESCRIPTION
|
||||
Convert gradians, m minutes, and s seconds returning gradians.
|
||||
|
||||
The return value in gradians, is quivalent to the following:
|
||||
|
||||
mod(d + m/60 + s/4000, 400, rnd);
|
||||
|
||||
Depending on the rounding mode, the return could be a real value
|
||||
in the interval [0, 400) or a real value in the interval (-400, 0].
|
||||
For the default round mode, the return value is in the interval [0, 400).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The gm2g(d, m, rnd) builtin is an alias for gms2g(d, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print gm2g(203, 325.5594);
|
||||
208.42599
|
||||
; print gm2g(4001, -25.5594);
|
||||
0.57401
|
||||
; print gm2g(-923, -25.5594);
|
||||
276.57401
|
||||
|
||||
; print gms2g(12, 20, 44.16);
|
||||
12.3456
|
||||
; print gms2g(123.456, -345.68, 4.08);
|
||||
117.6958
|
||||
; print gms2g(-65, -40, -44.4);
|
||||
334.321
|
||||
|
||||
; print gm2g(203, 325.5594, 1);
|
||||
-191.57401
|
||||
; print gms2g(12, 20, 44.16, 1);
|
||||
-387.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
|
||||
h2hm, h2hms, hm2d, hms2d, mod
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/25 17:24:51
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
84
help/hms2h
Normal file
84
help/hms2h
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
hm2h, hms2h - convert hours, minutes, and seconds to hours
|
||||
|
||||
SYNOPSIS
|
||||
hm2h(h, m [,rnd])
|
||||
hms2h(h, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
h real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return hours
|
||||
|
||||
DESCRIPTION
|
||||
Convert hours, m minutes, and s seconds returning hours.
|
||||
|
||||
The return value in hours, is quivalent to the following:
|
||||
|
||||
mod(h + m/60 + s/3600, 24, rnd);
|
||||
|
||||
Depending on the rounding mode, the return could be a real value
|
||||
in the interval [0, 24) or a real value in the interval (-24, 0].
|
||||
For the default round mode, the return value is in the interval [0, 24).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The hm2h(h, m, rnd) builtin is an alias for hms2h(h, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print hm2h(203, 325.5594);
|
||||
16.42599
|
||||
; print hm2h(241, -25.5594);
|
||||
0.57401
|
||||
; print hm2h(-923, -25.5594);
|
||||
12.57401
|
||||
|
||||
; print hms2h(12, 20, 44.16);
|
||||
12.3456
|
||||
; print hms2h(123.456, -345.68, 4.08);
|
||||
21.6958
|
||||
; print hms2h(-65, -40, -44.4);
|
||||
6.321
|
||||
|
||||
; print hm2h(203, 325.5594, 1);
|
||||
-7.57401
|
||||
; print hms2h(12, 20, 44.16, 1);
|
||||
-11.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
|
||||
h2hm, h2hms, hm2d, hms2d, mod
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/25 17:24:51
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
Reference in New Issue
Block a user