mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Added several conversion functions: Added builtin functions to convert between degrees and degrees, minutes and seconds under the config("mod") round rules: d2dms(degs, d, m, s [,rnd]) - given degs, compute d, m, s d2dm(degs, d, m [,rnd]) - given degs, compute d, m See help/d2dms and help/d2dm. Example: ; print d2dms(360.321,deg=,min=,sec=), deg, min, sec; 0.321 0 19 15.6 ; print d2dm(360.321,deg=,min=), deg, min; 0.321 0 19.26 Added builtin functions to convert between gradians and gradians, minutes and seconds under the config("mod") round rules: g2gms(grads, g, m, s [,rnd]) - given grads, compute g, m, s g2gm(grads, g, m [,rnd]) - given grads, compute g, m See help/g2gms and help/g2gm. Example: ; print g2gms(400.321,grad=,min=,sec=), grad, min, sec; 0.321 0 19 15.6 ; print g2gm(400.321,grad=,min=), grad, min; 0.321 0 19.26 Added builtin functions to convert between hours and hours, minutes and seconds under the config("mod") round rules: h2hms(hours, h, m, s [,rnd]) - given hours, compute h, m, s h2hm(hours, h, m [,rnd]) - given hours, compute h, m See help/h2hms and help/h2hm. Example: ; print h2hms(24.321,hour=,min=,sec=), hour, min, sec; 0.321 0 19 15.6 ; print h2hm(24.321,hour=,min=), hour, min; 0.321 0 19.26 In addtion: Renumbered regression tests 3408 thru 3437, to 9102 thru 9131. Updated Added hms.cal resource file to use h2hms() builtin. Updated Added dms.cal resource file to use d2dms() builtin. Fix minor typo in help/mod SYNOPSIS. Fix minor typo in help/quo SYNOPSIS. Added a few more examples to help/strcmp.
118 lines
3.6 KiB
Plaintext
118 lines
3.6 KiB
Plaintext
NAME
|
|
h2hm - convert hours into hours, and minutes
|
|
|
|
SYNOPSIS
|
|
h2hm(hours, h, m [,rnd])
|
|
|
|
TYPES
|
|
hours real
|
|
h null-or-real-valued lvalue with assign-to permission
|
|
m null-or-real-valued lvalue with assign-to permission
|
|
rnd nonnegative integer, defaults to config("mod")
|
|
|
|
return mod(hours, 24, rnd)
|
|
|
|
DESCRIPTION
|
|
Convert hours hours into h hours, and m minutes.
|
|
|
|
The return value is a normalized number of hours, and is equivalent
|
|
to the following:
|
|
|
|
return_value = mod(hours, 24, rnd);
|
|
|
|
The argument rnd, if not given, defaults to config("mod").
|
|
For more information on the effects of rnd, see "help mod".
|
|
|
|
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).
|
|
|
|
The h argument will be an integer number of hours.
|
|
|
|
The value h will be set as if the following were used:
|
|
|
|
h = int(return_value);
|
|
|
|
For some rounding modes, h will be an integer in the interval [0, 24).
|
|
For other rounding modes, h will be an integer in the interval (-24, 0].
|
|
For the default round mode, h is in the interval [0, 24).
|
|
|
|
The m argument will be a real number of minutes.
|
|
|
|
The value m will be set as if the following were used:
|
|
|
|
tmp = return_value - h;
|
|
m = tmp * 60;
|
|
free(tmp);
|
|
|
|
For some rounding modes, m will be a real value in the interval [0, 60).
|
|
For other rounding modes, m will be a real value in the interval (-60, 0].
|
|
For the default round mode, m will be in the interval [0, 60).
|
|
|
|
The following shows relationship between the return value and the resulting
|
|
h, and m values:
|
|
|
|
return_value == h + m/60;
|
|
|
|
|
|
EXAMPLE
|
|
/* if args are undefined, pre-declare them or assign them as args */
|
|
|
|
; global h, m;
|
|
|
|
; print h2hm(12.3456,h,m), h, m;
|
|
12.3456 12 20.736
|
|
; print h2hm(1234.5678,h,m), h, m;
|
|
10.5678 10 34.068
|
|
; print h2hm(-1234.5678,h,m), h, m;
|
|
13.4322 13 25.932
|
|
|
|
; print h2hm(654.321,hour=,min=), hour, min;
|
|
6.321 6 19.26
|
|
; print h2hm(-654.321,hour=,min=), hour, min;
|
|
17.679 17 40.74
|
|
; print h2hm(24.321,hour=,min=), hour, min;
|
|
0.321 0 19.26
|
|
|
|
/* certain non-default rounding modes can return negative values */
|
|
|
|
; print h2hm(654.321,hour=,min=,1), hour, min;
|
|
-17.679 -17 -40.74
|
|
; print h2hm(-654.321,hour=,min=,1), hour, min;
|
|
-6.321 -6 -19.26
|
|
; print h2hm(24.321,hour=,min=,1), hour, min;
|
|
-23.679 -23 -40.7
|
|
|
|
|
|
LIMITS
|
|
none
|
|
|
|
LINK LIBRARY
|
|
none
|
|
|
|
SEE ALSO
|
|
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
|
|
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/
|