Added several conversion funcions, plus minor updates

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.
This commit is contained in:
Landon Curt Noll
2021-09-26 04:38:09 -07:00
parent abf39b34b6
commit cf419fb329
20 changed files with 1836 additions and 138 deletions

View File

@@ -364,32 +364,33 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
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 d2g d2r \
delete den dereference det digit digits display 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 g2r gcd gcdrem gd \
getenv 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 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 matsum mattrace mattrans max memsize meq \
min minv mmin mne mod modify name near newerror nextcand nextprime \
norm null num oldvalue ord param perm pfact pi pix places pmod polar \
poly pop popcnt pound power prevcand prevprime printf prompt protect \
ptest push putenv quo quomod r2d r2g rand randbit random randombit \
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
round rsearch runtime saveval scale scan scanf search sec sech seed \
segment select sgn sha1 sin sinh size sizeof sleep sort sqrt srand \
srandom ssq stoponerror str strcasecmp strcat strcmp strcpy strerror \
strlen strncasecmp strncmp strncpy strpos strprintf strscan strscanf \
strtolower strtoupper substr sum swap system systime tail tan tanh \
test time trunc usertime version xor
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 \
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 \
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 \
matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
name near newerror nextcand nextprime norm null num oldvalue ord param \
perm pfact pi pix places pmod polar poly pop popcnt pound power \
prevcand prevprime printf prompt protect ptest push putenv quo quomod \
r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
rcsq re remove reverse rewind rm root round rsearch runtime saveval \
scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
sum swap system systime tail tan tanh test time trunc usertime version \
xor
# This list is of files that are clones of DETAIL_HELP files. They are
# built from DETAIL_HELP files.

117
help/d2dm Normal file
View File

@@ -0,0 +1,117 @@
NAME
d2dm - convert degrees into degrees, and minutes
SYNOPSIS
d2dm(degs, d, m [,rnd])
TYPES
degs real
d 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(degs, 360, rnd)
DESCRIPTION
Convert degs degrees into d degrees, and m minutes.
The return value is a normalized number of degrees, and is equivalent
to the following:
return_value = mod(degs, 360, 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, 360) or a real value in the interval (-360, 0].
For the default round mode, the return value is in the interval [0, 360).
The d argument will be an integer number of degrees.
The value d will be set as if the following were used:
d = int(return_value);
For some rounding modes, d will be an integer in the interval [0, 360).
For other rounding modes, d will be an integer in the interval (-360, 0].
For the default round mode, d is in the interval [0, 360).
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 - d;
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
d, and m values:
return_value == d + m/60;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global d, m;
; print d2dm(12.3456,d,m), d, m;
12.3456 12 20.736
; print d2dm(1234.5678,d,m), d, m;
154.5678 154 34.068
; print d2dm(-1234.5678,d,m), d, m;
205.4322 205 25.932
; print d2dm(654.321,deg=,min=), deg, min;
294.321 294 19.26
; print d2dm(-654.321,deg=,min=), deg, min;
65.679 65 40.74
; print d2dm(360.321,deg=,min=), deg, min;
0.321 0 19.26
/* certain non-default rounding modes can return negative values */
; print d2dm(654.321,deg=,min=,1), deg, min;
-65.679 -65 -40.74
; print d2dm(-654.321,deg=,min=,1), deg, min;
-294.321 -294 -19.26
; print d2dm(360.321,deg=,min=,1), deg, min;
-359.679 -359 -40.74
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, 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/

132
help/d2dms Normal file
View File

@@ -0,0 +1,132 @@
NAME
d2dms - convert degrees into degrees, minutes, and seconds
SYNOPSIS
d2dms(degs, d, m, s [,rnd])
TYPES
degs real
d null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(degs, 360, rnd)
DESCRIPTION
Convert degs degrees into d degrees, m minutes, and s seconds.
The return value is a normalized number of degrees, and is equivalent
to the following:
return_value = mod(degs, 360, 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, 360) or a real value in the interval (-360, 0].
For the default round mode, the return value is in the interval [0, 360).
The d argument will be an integer number of degrees.
The value d will be set as if the following were used:
d = int(return_value);
For some rounding modes, d will be an integer in the interval [0, 360).
For other rounding modes, d will be an integer in the interval (-360, 0].
For the default round mode, d is in the interval [0, 360).
The m argument will be an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - d;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
d, m, and s values:
return_value == d + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global d, m, s;
; print d2dms(12.3456,d,m,s), d, m, s;
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;
205.4322 205 25 55.92
; print d2dms(654.321,deg=,min=,sec=), deg, min, sec;
294.321, 294, 19, 15.6
; print d2dms(-654.321,deg=,min=,sec=), deg, min, sec;
65.679 65 40 44.4
; print d2dms(360.321,deg=,min=,sec=), deg, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print d2dms(654.321,deg=,min=,sec=,1), deg, min, sec;
-65.679 -65 -40 -44.4
; print d2dms(-654.321,deg=,min=,sec=,1), deg, min, sec;
-294.321 -294 -19 -15.6
; print d2dms(360.321,deg=,min=,sec=,1), deg, min, sec;
-359.679 -359 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, 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/

117
help/g2gm Normal file
View File

@@ -0,0 +1,117 @@
NAME
g2gm - convert gradians into gradians, and minutes
SYNOPSIS
g2gm(grads, g, m [,rnd])
TYPES
grads real
g 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(grads, 400, rnd)
DESCRIPTION
Convert grads gradians into g gradians, and m minutes.
The return value is a normalized number of gradians, and is equivalent
to the following:
return_value = mod(grads, 400, 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, 400) or a real value in the interval (-400, 0].
For the default round mode, the return value is in the interval [0, 400).
The g argument will be an integer number of gradians.
The value g will be set as if the following were used:
g = int(return_value);
For some rounding modes, g will be an integer in the interval [0, 400).
For other rounding modes, g will be an integer in the interval (-400, 0].
For the default round mode, g is in the interval [0, 400).
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 - g;
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
g, and m values:
return_value == g + m/60;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global g, m;
; print g2gm(12.3456,g,m), g, m;
12.3456 12 20.736
; print g2gm(1234.5678,g,m), g, m;
34.5678 34 34.068
; print g2gm(-1234.5678,g,m), g, m;
365.4322 365 25.932
; print g2gm(654.321,grad=,min=), grad, min;
254.321 254 19.26
; print g2gm(-654.321,grad=,min=), grad, min;
145.679 145 40.74
; print g2gm(400.321,grad=,min=), grad, min;
0.321 0 19.26
/* certain non-default rounding modes can return negative values */
; print g2gm(654.321,grad=,min=,1), grad, min;
-145.679 -145 -40.74
; print g2gm(-654.321,grad=,min=,1), grad, min;
-254.321 -254 -19.26
; print g2gm(400.321,grad=,min=,1), grad, min;
-399.679 -399 -40.74
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, 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/

132
help/g2gms Normal file
View File

@@ -0,0 +1,132 @@
NAME
g2gms - convert gradians into gradians, minutes, and seconds
SYNOPSIS
g2gms(grads, g, m, s [,rnd])
TYPES
grads real
g null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(grads, 400, rnd)
DESCRIPTION
Convert grads gradians into g gradians, m minutes, and s seconds.
The return value is a normalized number of gradians, and is equivalent
to the following:
return_value = mod(grads, 400, 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, 400) or a real value in the interval (-400, 0].
For the default round mode, the return value is in the interval [0, 400).
The g argument will be an integer number of gradians.
The value g will be set as if the following were used:
g = int(return_value);
For some rounding modes, g will be an integer in the interval [0, 400).
For other rounding modes, g will be an integer in the interval (-400, 0].
For the default round mode, g is in the interval [0, 400).
The m argument will be an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - g;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
g, m, and s values:
return_value == g + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global g, m, s;
; print g2gms(12.3456,g,m,s), g, m, s;
12.3456 12 20 44.16
; print g2gms(1234.5678,g,m,s), g, m, s;
34.5678 34 34 4.08
; print g2gms(-1234.5678,g,m,s), g, m, s;
365.4322 365 25 55.92
; print g2gms(654.321,grad=,min=,sec=), grad, min, sec;
254.321 254 19 15.6
; print g2gms(-654.321,grad=,min=,sec=), grad, min, sec;
145.679 145 40 44.4
; print g2gms(400.321,grad=,min=,sec=), grad, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print g2gms(654.321,grad=,min=,sec=,1), grad, min, sec;
-145.679 -145 -40 -44.4
; print g2gms(-654.321,grad=,min=,sec=,1), grad, min, sec;
-254.321 -254 -19 -15.6
; print g2gms(400.321,grad=,min=,sec=,1), grad, min, sec;
-399.679 -399 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gm, 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/

117
help/h2hm Normal file
View File

@@ -0,0 +1,117 @@
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/

132
help/h2hms Normal file
View File

@@ -0,0 +1,132 @@
NAME
h2hms - convert hours into hours, minutes, and seconds
SYNOPSIS
h2hms(hours, h, m, s [,rnd])
TYPES
hours real
h null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s 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, m minutes, and s seconds.
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 an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - h;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
h, m, and s values:
return_value == h + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global h, m, s;
; print h2hms(12.3456,h,m,s), h, m, s;
12.3456 12 20 44.16
; print h2hms(1234.5678,h,m,s), h, m, s;
10.5678 10 34 4.08
; print h2hms(-1234.5678,h,m,s), h, m, s;
13.4322 13 25 55.92
; print h2hms(654.321,hour=,min=,sec=), hour, min, sec;
6.321 6 19 15.6
; print h2hms(-654.321,hour=,min=,sec=), hour, min, sec;
17.679 17 40 44.4
; print h2hms(24.321,hour=,min=,sec=), hour, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print h2hms(654.321,hour=,min=,sec=,1), hour, min, sec;
-17.679 -17 -40 -44.4
; print h2hms(-654.321,hour=,min=,sec=,1), hour, min, sec;
-6.321 -6 -19 -15.6
; print h2hms(24.321,hour=,min=,sec=,1), hour, min, sec;
-23.679 -23 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
h2hm, 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/

View File

@@ -2,7 +2,7 @@ NAME
mod - compute the remainder for an integer quotient
SYNOPSIS
mod(x, y, rnd)
mod(x, y [,rnd])
x % y
TYPES

View File

@@ -2,7 +2,7 @@ NAME
quo - compute integer quotient of a value by a real number
SYNOPSIS
quo(x, y, rnd) or x // y
quo(x, y [,rnd]) or x // y
TYPES
If x is a matrix or list, the returned value is a matrix or list v of

View File

@@ -26,6 +26,8 @@ EXAMPLE
strcmp("abc", "abb") == 1
strcmp("abc", "abc") == 0
strcmp("abc", "abd") == -1
strcmp("desk", "Shabisky") == 1
strcmp("Shabisky", "desk") == -1
strcmp("abc\0", "abc") == 1
strcmp("a\0b", "a\0c") == -1
@@ -39,7 +41,7 @@ SEE ALSO
strcat, strcpy, strerror, strlen, strncmp, strncpy, strpos,
strprintf, strscan, strscanf, substr
## Copyright (C) 2006 Ernest Bowen
## Copyright (C) 2006,2021 Ernest Bowen
##
## 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