mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
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:
63
CHANGES
63
CHANGES
@@ -78,10 +78,71 @@ The following are the changes from calc version 2.14.0.0 to date:
|
|||||||
More changes are likely, so we might see another v2.14.0.x release
|
More changes are likely, so we might see another v2.14.0.x release
|
||||||
before things are declared "recommended stable".
|
before things are declared "recommended stable".
|
||||||
|
|
||||||
Not that we wan to discourage people from trying v2.14.0, you should
|
Not that we want to discourage people from trying v2.14.0, you should
|
||||||
try it. We just want things to become stable and well field tested
|
try it. We just want things to become stable and well field tested
|
||||||
before we reach the "recommended stable" release state.
|
before we reach the "recommended stable" release state.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:
|
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:
|
||||||
|
|
||||||
|
20
cal/dms.cal
20
cal/dms.cal
@@ -352,24 +352,8 @@ define fixdms(a)
|
|||||||
quit "attempt to fix a non dms object";
|
quit "attempt to fix a non dms object";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force minutes to be integral */
|
/* use builtin d2dms function */
|
||||||
a.min += frac(a.deg) * 60;
|
d2dms(a.deg + a.min/60 + a.sec/3600, a.deg, a.min, a.sec),;
|
||||||
a.deg = int(a.deg);
|
|
||||||
|
|
||||||
/* force degrees to be integral */
|
|
||||||
a.sec += frac(a.min) * 60;
|
|
||||||
a.min = int(a.min);
|
|
||||||
|
|
||||||
/* carry excess seconds into minutes */
|
|
||||||
a.min += a.sec // 60;
|
|
||||||
a.sec %= 60;
|
|
||||||
|
|
||||||
/* carry excess minutes into degrees */
|
|
||||||
a.deg += a.min // 60;
|
|
||||||
a.min %= 60;
|
|
||||||
|
|
||||||
/* round degrees :-) */
|
|
||||||
a.deg %= 360;
|
|
||||||
|
|
||||||
/* return normalized result */
|
/* return normalized result */
|
||||||
return a;
|
return a;
|
||||||
|
20
cal/hms.cal
20
cal/hms.cal
@@ -352,24 +352,8 @@ define fixhms(a)
|
|||||||
quit "attempt to fix a non hms object";
|
quit "attempt to fix a non hms object";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force minutes to be integral */
|
/* use builtin h2hms function */
|
||||||
a.min += frac(a.hour) * 60;
|
h2hms(a.hour + a.min/60 + a.sec/3600, a.hour, a.min, a.sec),;
|
||||||
a.hour = int(a.hour);
|
|
||||||
|
|
||||||
/* force hours to be integral */
|
|
||||||
a.sec += frac(a.min) * 60;
|
|
||||||
a.min = int(a.min);
|
|
||||||
|
|
||||||
/* carry excess seconds into minutes */
|
|
||||||
a.min += a.sec // 60;
|
|
||||||
a.sec %= 60;
|
|
||||||
|
|
||||||
/* carry excess minutes into hours */
|
|
||||||
a.hour += a.min // 60;
|
|
||||||
a.min %= 60;
|
|
||||||
|
|
||||||
/* round hours by day */
|
|
||||||
a.hour %= 24;
|
|
||||||
|
|
||||||
/* return normalized result */
|
/* return normalized result */
|
||||||
return a;
|
return a;
|
||||||
|
361
cal/regress.cal
361
cal/regress.cal
@@ -775,7 +775,9 @@ print '016: parsed test_bignums()';
|
|||||||
/*
|
/*
|
||||||
* Test many of the built-in functions.
|
* Test many of the built-in functions.
|
||||||
*
|
*
|
||||||
* See test_functionss() starting at test 9000 for more built-in function tests.
|
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||||
|
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||||
|
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||||
*/
|
*/
|
||||||
define test_functions()
|
define test_functions()
|
||||||
{
|
{
|
||||||
@@ -3404,74 +3406,6 @@ define test_trig()
|
|||||||
tnum = test3400(1, 3401);
|
tnum = test3400(1, 3401);
|
||||||
vrfy(tnum == 3407, '3407: tnum == 3407');
|
vrfy(tnum == 3407, '3407: tnum == 3407');
|
||||||
|
|
||||||
/* d2r & r2d */
|
|
||||||
vrfy(d2r(180) == pi(),
|
|
||||||
'3408: d2r(180) == pi()');
|
|
||||||
vrfy(d2r(180, 1e-100) == pi(1e-100),
|
|
||||||
'3409: d2r(180, 1e-100) == pi(1e-100)');
|
|
||||||
vrfy(r2d(pi()/2) == 90,
|
|
||||||
'3410: r2d(pi()/2) == 90');
|
|
||||||
vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923,
|
|
||||||
'3411: r2d(pi(1e-15)/2) == ' +
|
|
||||||
'14137166941154068500000/157079632679489661923');
|
|
||||||
vrfy(r2d(d2r(40)) == 40,
|
|
||||||
'3412: r2d(d2r(40)) == 40');
|
|
||||||
vrfy(r2d(d2r(40,1e-90),1e-90) == 40,
|
|
||||||
'3413: r2d(d2r(40,1e-90),1e-90) == 40');
|
|
||||||
vrfy(d2r(180i) == 1i*pi(),
|
|
||||||
'3414: d2r(1808) == 1i*pi()');
|
|
||||||
vrfy(d2r(180i+90) == 1i*pi() + pi()/2,
|
|
||||||
'3415: d2r(180i+90) == 1i*pi() + pi()/2');
|
|
||||||
vrfy(r2d(d2r(40+40i)) == 40+40i,
|
|
||||||
'3416: r2d(d2r(40+40i)) == 40+40i');
|
|
||||||
vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i,
|
|
||||||
'3417: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i');
|
|
||||||
|
|
||||||
/* g2r & r2g */
|
|
||||||
vrfy(g2r(200) == pi(),
|
|
||||||
'3418: g2r(200) == pi()');
|
|
||||||
vrfy(g2r(200, 1e-100) == pi(1e-100),
|
|
||||||
'3419: g2r(180, 1e-100) == pi(1e-100)');
|
|
||||||
vrfy(r2g(pi()/2) == 100,
|
|
||||||
'3420: r2g(pi()/2) == 100');
|
|
||||||
vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923,
|
|
||||||
'3421: r2g(pi(1e-15)/2) == ' +
|
|
||||||
'15707963267948965000000/157079632679489661923');
|
|
||||||
vrfy(r2g(g2r(40)) == 40,
|
|
||||||
'3422: r2g(g2r(40)) == 40');
|
|
||||||
vrfy(r2g(g2r(40,1e-90),1e-90) == 40,
|
|
||||||
'3423: r2g(g2r(40,1e-90),1e-90) == 40');
|
|
||||||
vrfy(g2r(200i) == 1i*pi(),
|
|
||||||
'3424: g2r(200i) == 1i*pi()');
|
|
||||||
vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(),
|
|
||||||
'3425: g2r(200i+150) == pi()*0.75 + 1i*pi()');
|
|
||||||
vrfy(r2g(g2r(40+40i)) == 40+40i,
|
|
||||||
'3426: r2g(g2r(40+40i)) == 40+40i');
|
|
||||||
vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i,
|
|
||||||
'3427: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i');
|
|
||||||
|
|
||||||
/* g2d & d2g */
|
|
||||||
vrfy(g2d(200) == 180,
|
|
||||||
'3428: g2d(200) == 180');
|
|
||||||
vrfy(g2d(200, 1e-100) == 180,
|
|
||||||
'3429: g2d(180, 1e-100) == 180');
|
|
||||||
vrfy(d2g(81) == 90,
|
|
||||||
'3430: d2g(81) == 90');
|
|
||||||
vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000,
|
|
||||||
'3431: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000');
|
|
||||||
vrfy(d2g(g2d(40)) == 40,
|
|
||||||
'3432: d2g(g2d(40)) == 40');
|
|
||||||
vrfy(d2g(g2d(40,1e-90),1e-90) == 40,
|
|
||||||
'3433: d2g(g2d(40,1e-90),1e-90) == 40');
|
|
||||||
vrfy(g2d(200i) == 180i,
|
|
||||||
'3434: g2d(200i) == 180i');
|
|
||||||
vrfy(g2d(200i+47) == 42.3 + 180i,
|
|
||||||
'3435: g2d(200i+47) == 42.3 + 180i');
|
|
||||||
vrfy(d2g(g2d(40+40i)) == 40+40i,
|
|
||||||
'3436: d2g(g2d(40+40i)) == 40+40i');
|
|
||||||
vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i,
|
|
||||||
'3437: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i');
|
|
||||||
|
|
||||||
print '3438: Ending test_trig';
|
print '3438: Ending test_trig';
|
||||||
}
|
}
|
||||||
print '051: parsed test_trig()';
|
print '051: parsed test_trig()';
|
||||||
@@ -8235,6 +8169,8 @@ ecnt = 211;
|
|||||||
* Test more of the built-in functions.
|
* Test more of the built-in functions.
|
||||||
*
|
*
|
||||||
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||||
|
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||||
|
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||||
*/
|
*/
|
||||||
define test_functions2()
|
define test_functions2()
|
||||||
{
|
{
|
||||||
@@ -8348,6 +8284,293 @@ print;
|
|||||||
return test_functions2();
|
return test_functions2();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test even more of the built-in functions.
|
||||||
|
*
|
||||||
|
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||||
|
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||||
|
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||||
|
*/
|
||||||
|
define test_functions3()
|
||||||
|
{
|
||||||
|
local d, m, s, g, h;
|
||||||
|
|
||||||
|
print '9101: Beginning test_functions3';
|
||||||
|
|
||||||
|
/* d2r & r2d */
|
||||||
|
vrfy(d2r(180) == pi(),
|
||||||
|
'9102: d2r(180) == pi()');
|
||||||
|
vrfy(d2r(180, 1e-100) == pi(1e-100),
|
||||||
|
'9103: d2r(180, 1e-100) == pi(1e-100)');
|
||||||
|
vrfy(r2d(pi()/2) == 90,
|
||||||
|
'9104: r2d(pi()/2) == 90');
|
||||||
|
vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923,
|
||||||
|
'9105: r2d(pi(1e-15)/2) == ' +
|
||||||
|
'14137166941154068500000/157079632679489661923');
|
||||||
|
vrfy(r2d(d2r(40)) == 40,
|
||||||
|
'9106: r2d(d2r(40)) == 40');
|
||||||
|
vrfy(r2d(d2r(40,1e-90),1e-90) == 40,
|
||||||
|
'9107: r2d(d2r(40,1e-90),1e-90) == 40');
|
||||||
|
vrfy(d2r(180i) == 1i*pi(),
|
||||||
|
'9108: d2r(1808) == 1i*pi()');
|
||||||
|
vrfy(d2r(180i+90) == 1i*pi() + pi()/2,
|
||||||
|
'9109: d2r(180i+90) == 1i*pi() + pi()/2');
|
||||||
|
vrfy(r2d(d2r(40+40i)) == 40+40i,
|
||||||
|
'9110: r2d(d2r(40+40i)) == 40+40i');
|
||||||
|
vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||||
|
'9111: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||||
|
|
||||||
|
/* g2r & r2g */
|
||||||
|
vrfy(g2r(200) == pi(),
|
||||||
|
'9112: g2r(200) == pi()');
|
||||||
|
vrfy(g2r(200, 1e-100) == pi(1e-100),
|
||||||
|
'9113: g2r(180, 1e-100) == pi(1e-100)');
|
||||||
|
vrfy(r2g(pi()/2) == 100,
|
||||||
|
'9114: r2g(pi()/2) == 100');
|
||||||
|
vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923,
|
||||||
|
'9115: r2g(pi(1e-15)/2) == ' +
|
||||||
|
'15707963267948965000000/157079632679489661923');
|
||||||
|
vrfy(r2g(g2r(40)) == 40,
|
||||||
|
'9116: r2g(g2r(40)) == 40');
|
||||||
|
vrfy(r2g(g2r(40,1e-90),1e-90) == 40,
|
||||||
|
'9117: r2g(g2r(40,1e-90),1e-90) == 40');
|
||||||
|
vrfy(g2r(200i) == 1i*pi(),
|
||||||
|
'9118: g2r(200i) == 1i*pi()');
|
||||||
|
vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(),
|
||||||
|
'9119: g2r(200i+150) == pi()*0.75 + 1i*pi()');
|
||||||
|
vrfy(r2g(g2r(40+40i)) == 40+40i,
|
||||||
|
'9120: r2g(g2r(40+40i)) == 40+40i');
|
||||||
|
vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||||
|
'9121: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||||
|
|
||||||
|
/* g2d & d2g */
|
||||||
|
vrfy(g2d(200) == 180,
|
||||||
|
'9122: g2d(200) == 180');
|
||||||
|
vrfy(g2d(200, 1e-100) == 180,
|
||||||
|
'9123: g2d(180, 1e-100) == 180');
|
||||||
|
vrfy(d2g(81) == 90,
|
||||||
|
'9124: d2g(81) == 90');
|
||||||
|
vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000,
|
||||||
|
'9125: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000');
|
||||||
|
vrfy(d2g(g2d(40)) == 40,
|
||||||
|
'9126: d2g(g2d(40)) == 40');
|
||||||
|
vrfy(d2g(g2d(40,1e-90),1e-90) == 40,
|
||||||
|
'9127: d2g(g2d(40,1e-90),1e-90) == 40');
|
||||||
|
vrfy(g2d(200i) == 180i,
|
||||||
|
'9128: g2d(200i) == 180i');
|
||||||
|
vrfy(g2d(200i+47) == 42.3 + 180i,
|
||||||
|
'9129: g2d(200i+47) == 42.3 + 180i');
|
||||||
|
vrfy(d2g(g2d(40+40i)) == 40+40i,
|
||||||
|
'9130: d2g(g2d(40+40i)) == 40+40i');
|
||||||
|
vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i,
|
||||||
|
'9131: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i');
|
||||||
|
|
||||||
|
/* d2dms */
|
||||||
|
vrfy(d2dms(12.3456,d,m,s) == 12.3456,
|
||||||
|
'9132: d2dms(12.3456,d,m,s) == 12.3456');
|
||||||
|
vrfy(d == 12,
|
||||||
|
'9133: d == 12');
|
||||||
|
vrfy(m == 20,
|
||||||
|
'9133: m == 20');
|
||||||
|
vrfy(s == 44.16,
|
||||||
|
'9134: s == 44.16');
|
||||||
|
|
||||||
|
vrfy(d2dms(1234.5678,d,m,s) == 154.5678,
|
||||||
|
'9135: d2dms(1234.5678,d,m,s) == 154.5678');
|
||||||
|
vrfy(d == 154,
|
||||||
|
'9136: d == 154');
|
||||||
|
vrfy(m == 34,
|
||||||
|
'9137: m == 34');
|
||||||
|
vrfy(s == 4.08,
|
||||||
|
'9138: s == 4.08');
|
||||||
|
|
||||||
|
vrfy(d2dms(-1234.5678,d,m,s) == 205.4322,
|
||||||
|
'9139: d2dms(-1234.5678,d,m,s) == 205.4322');
|
||||||
|
vrfy(d == 205,
|
||||||
|
'9140: d == 205');
|
||||||
|
vrfy(m == 25,
|
||||||
|
'9141: m == 25');
|
||||||
|
vrfy(s == 55.92,
|
||||||
|
'9142: s == 55.92');
|
||||||
|
|
||||||
|
vrfy(d2dms(360.321,d,m,s,1) == -359.679,
|
||||||
|
'9143: d2dms(360.321,d,m,s,1) == -359.679');
|
||||||
|
vrfy(d == -359,
|
||||||
|
'9144: d == -359');
|
||||||
|
vrfy(m == -40,
|
||||||
|
'9145: m == -40');
|
||||||
|
vrfy(s == -44.4,
|
||||||
|
'9146: s == -44.4');
|
||||||
|
|
||||||
|
/* d2dm */
|
||||||
|
vrfy(d2dm(12.3456,d,m) == 12.3456,
|
||||||
|
'9147: d2dm(12.3456,d,m) == 12.3456');
|
||||||
|
vrfy(d == 12,
|
||||||
|
'9148: d == 12');
|
||||||
|
vrfy(m == 20.736,
|
||||||
|
'9149: m == 20.736');
|
||||||
|
|
||||||
|
vrfy(d2dm(1234.5678,d,m) == 154.5678,
|
||||||
|
'9150: d2dm(1234.5678,d,m) == 154.5678');
|
||||||
|
vrfy(d == 154,
|
||||||
|
'9151: d == 154');
|
||||||
|
vrfy(m == 34.068,
|
||||||
|
'9152: m == 34.068');
|
||||||
|
|
||||||
|
vrfy(d2dm(-1234.5678,d,m) == 205.4322,
|
||||||
|
'9153: d2dm(-1234.5678,d,m) == 205.4322');
|
||||||
|
vrfy(d == 205,
|
||||||
|
'9154: d == 205');
|
||||||
|
vrfy(m == 25.932,
|
||||||
|
'9155: m == 25.932');
|
||||||
|
|
||||||
|
vrfy(d2dm(360.321,d,m,1) == -359.679,
|
||||||
|
'9156: d2dm(360.321,d,m,1) == -359.679');
|
||||||
|
vrfy(d == -359,
|
||||||
|
'9167: d == -359');
|
||||||
|
vrfy(m == -40.74,
|
||||||
|
'9158: m == -40.74');
|
||||||
|
|
||||||
|
/* g2gms */
|
||||||
|
vrfy(g2gms(12.3456,g,m,s) == 12.3456,
|
||||||
|
'9159: g2gms(12.3456,g,m,s) == 12.3456');
|
||||||
|
vrfy(g == 12,
|
||||||
|
'9133: g == 12');
|
||||||
|
vrfy(m == 20,
|
||||||
|
'9160: m == 20');
|
||||||
|
vrfy(s == 44.16,
|
||||||
|
'9161: s == 44.16');
|
||||||
|
|
||||||
|
vrfy(g2gms(1234.5678,g,m,s) == 34.5678,
|
||||||
|
'9162: g2gms(1234.5678,g,m,s) == 34.5678');
|
||||||
|
vrfy(g == 34,
|
||||||
|
'9163: g == 34');
|
||||||
|
vrfy(m == 34,
|
||||||
|
'9164: m == 34');
|
||||||
|
vrfy(s == 4.08,
|
||||||
|
'9165: s == 4.08');
|
||||||
|
|
||||||
|
vrfy(g2gms(-1234.5678,g,m,s) == 365.4322,
|
||||||
|
'9166: g2gms(-1234.5678,g,m,s) == 365.4322');
|
||||||
|
vrfy(g == 365,
|
||||||
|
'9167: g == 365');
|
||||||
|
vrfy(m == 25,
|
||||||
|
'9168: m == 25');
|
||||||
|
vrfy(s == 55.92,
|
||||||
|
'9169: s == 55.92');
|
||||||
|
|
||||||
|
vrfy(g2gms(400.321,g,m,s,1) == -399.679,
|
||||||
|
'9170: g2gms(400.321,g,m,s,1) == -399.679');
|
||||||
|
vrfy(g == -399,
|
||||||
|
'9171: g == -399');
|
||||||
|
vrfy(m == -40,
|
||||||
|
'9172: m == -40');
|
||||||
|
vrfy(s == -44.4,
|
||||||
|
'9173: s == -44.4');
|
||||||
|
|
||||||
|
/* g2gm */
|
||||||
|
vrfy(g2gm(12.3456,g,m) == 12.3456,
|
||||||
|
'9174: g2gm(12.3456,g,m) == 12.3456');
|
||||||
|
vrfy(g == 12,
|
||||||
|
'9175: g == 12');
|
||||||
|
vrfy(m == 20.736,
|
||||||
|
'9176: m == 20.736');
|
||||||
|
|
||||||
|
vrfy(g2gm(1234.5678,g,m) == 34.5678,
|
||||||
|
'9177: g2gm(1234.5678,g,m) == 34.5678');
|
||||||
|
vrfy(g == 34,
|
||||||
|
'9178: g == 34');
|
||||||
|
vrfy(m == 34.068,
|
||||||
|
'9179: m == 34.068');
|
||||||
|
|
||||||
|
vrfy(g2gm(-1234.5678,g,m) == 365.4322,
|
||||||
|
'9180: g2gm(-1234.5678,g,m) == 365.4322');
|
||||||
|
vrfy(g == 365,
|
||||||
|
'9181: g == 365');
|
||||||
|
vrfy(m == 25.932,
|
||||||
|
'9182: m == 25.932');
|
||||||
|
|
||||||
|
vrfy(g2gm(400.321,g,m,1) == -399.679,
|
||||||
|
'9183: g2gm(400.321,g,m,1) == -399.679');
|
||||||
|
vrfy(g == -399,
|
||||||
|
'9184: g == -399');
|
||||||
|
vrfy(m == -40.74,
|
||||||
|
'9185: m == -40.74');
|
||||||
|
|
||||||
|
/* h2hms */
|
||||||
|
vrfy(h2hms(12.3456,h,m,s) == 12.3456,
|
||||||
|
'9186: h2hms(12.3456,h,m,s) == 12.3456');
|
||||||
|
vrfy(h == 12,
|
||||||
|
'9187: h == 12');
|
||||||
|
vrfy(m == 20,
|
||||||
|
'9188: m == 20');
|
||||||
|
vrfy(s == 44.16,
|
||||||
|
'9189: s == 44.16');
|
||||||
|
|
||||||
|
vrfy(h2hms(1234.5678,h,m,s) == 10.5678,
|
||||||
|
'9190: h2hms(1234.5678,h,m,s) == 10.5678');
|
||||||
|
vrfy(h == 10,
|
||||||
|
'9191: h == 10');
|
||||||
|
vrfy(m == 34,
|
||||||
|
'9192: m == 34');
|
||||||
|
vrfy(s == 4.08,
|
||||||
|
'9193: s == 4.08');
|
||||||
|
|
||||||
|
vrfy(h2hms(-1234.5678,h,m,s) == 13.4322,
|
||||||
|
'9194: h2hms(-1234.5678,h,m,s) == 13.4322');
|
||||||
|
vrfy(h == 13,
|
||||||
|
'9195: h == 13');
|
||||||
|
vrfy(m == 25,
|
||||||
|
'9196: m == 25');
|
||||||
|
vrfy(s == 55.92,
|
||||||
|
'9197: s == 55.92');
|
||||||
|
|
||||||
|
vrfy(h2hms(24.321,h,m,s,1) == -23.679,
|
||||||
|
'9198: h2hms(24.321,h,m,s,1) == -23.679');
|
||||||
|
vrfy(h == -23,
|
||||||
|
'9199: h == -23');
|
||||||
|
vrfy(m == -40,
|
||||||
|
'9200: m == -40');
|
||||||
|
vrfy(s == -44.4,
|
||||||
|
'9201: s == -44.4');
|
||||||
|
|
||||||
|
/* h2hm */
|
||||||
|
vrfy(h2hm(12.3456,h,m) == 12.3456,
|
||||||
|
'9202: h2hm(12.3456,h,m) == 12.3456');
|
||||||
|
vrfy(h == 12,
|
||||||
|
'9203: h == 12');
|
||||||
|
vrfy(m == 20.736,
|
||||||
|
'9204: m == 20.736');
|
||||||
|
|
||||||
|
vrfy(h2hm(1234.5678,h,m) == 10.5678,
|
||||||
|
'9205: h2hm(1234.5678,h,m) == 10.5678');
|
||||||
|
vrfy(h == 10,
|
||||||
|
'9206: h == 10');
|
||||||
|
vrfy(m == 34.068,
|
||||||
|
'9207: m == 34.068');
|
||||||
|
|
||||||
|
vrfy(h2hm(-1234.5678,h,m) == 13.4322,
|
||||||
|
'9208: h2hm(-1234.5678,h,m) == 13.4322');
|
||||||
|
vrfy(h == 13,
|
||||||
|
'9209: h == 13');
|
||||||
|
vrfy(m == 25.932,
|
||||||
|
'9210: m == 25.932');
|
||||||
|
|
||||||
|
vrfy(h2hm(24.321,h,m,1) == -23.679,
|
||||||
|
'9211: h2hm(24.321,h,m,1) == -23.679');
|
||||||
|
vrfy(h == -23,
|
||||||
|
'9212: h == -23');
|
||||||
|
vrfy(m == -40.74,
|
||||||
|
'9213: m == -40.74');
|
||||||
|
|
||||||
|
print '9214: Ending test_functions3';
|
||||||
|
}
|
||||||
|
print;
|
||||||
|
print '9100: parsed test_functions3()';
|
||||||
|
print;
|
||||||
|
return test_functions3();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read various calc resource files
|
* read various calc resource files
|
||||||
*
|
*
|
||||||
|
18
calcerr.tbl
18
calcerr.tbl
@@ -506,3 +506,21 @@ E_R2G1 Bad epsilon for converting radians to gradians
|
|||||||
E_R2G2 Bad first argument converting radians to gradians
|
E_R2G2 Bad first argument converting radians to gradians
|
||||||
E_D2G1 Bad first argument converting degrees to gradians
|
E_D2G1 Bad first argument converting degrees to gradians
|
||||||
E_G2D1 Bad first argument converting gradians to degrees
|
E_G2D1 Bad first argument converting gradians to degrees
|
||||||
|
E_D2DMS1 Non-lvalue arguments 2, 3 or 4 for d2dms
|
||||||
|
E_D2DMS2 Non-real-number arg 1 for d2dms
|
||||||
|
E_D2DMS3 No-assign-to argument 2, 3 or 4 for d2dms
|
||||||
|
E_D2DM1 Non-lvalue arguments 2 or 3 for d2dm
|
||||||
|
E_D2DM2 Non-real-number arg 1 for d2dm
|
||||||
|
E_D2DM3 No-assign-to argument 2 or 3 for d2dm
|
||||||
|
E_G2GMS1 Non-lvalue arguments 2, 3 or 4 for g2gms
|
||||||
|
E_G2GMS2 Non-real-number arg 1 for g2gms
|
||||||
|
E_G2GMS3 No-assign-to argument 2 or 3 for g2gm
|
||||||
|
E_G2GM1 Non-lvalue arguments 2 or 3 for g2gm
|
||||||
|
E_G2GM2 Non-real-number arg 1 for g2gm
|
||||||
|
E_G2GM3 No-assign-to argument 2, 3 or 4 for g2gms
|
||||||
|
E_H2HMS1 Non-lvalue arguments 2, 3 or 4 for h2hms
|
||||||
|
E_H2HMS2 Non-real-number arg 1 for h2hms
|
||||||
|
E_H2HMS3 No-assign-to argument 2, 3 or 4 for h2hms
|
||||||
|
E_H2HM1 Non-lvalue arguments 2 or 3 for h2hm
|
||||||
|
E_H2HM2 Non-real-number arg 1 for h2hm
|
||||||
|
E_H2HM3 No-assign-to argument 2 or 3 for h2hm
|
||||||
|
664
func.c
664
func.c
@@ -3936,6 +3936,658 @@ f_quomod(int count, VALUE **vals)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_d2dms(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4, *v5;
|
||||||
|
NUMBER *tmp, *tmp_m;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
v4 = vals[3];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 5) {
|
||||||
|
v5 = vals[4];
|
||||||
|
if (v5->v_type == V_ADDR) {
|
||||||
|
v5 = v5->v_addr;
|
||||||
|
}
|
||||||
|
if (v5->v_type != V_NUM || qisfrac(v5->v_num) ||
|
||||||
|
qisneg(v5->v_num) || zge31b(v5->v_num->num)) {
|
||||||
|
return error_value(E_D2DMS2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v5->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR ||
|
||||||
|
v4->v_type != V_ADDR) {
|
||||||
|
return error_value(E_D2DMS1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL) ||
|
||||||
|
(v4->v_type != V_NUM && v4->v_type != V_NULL)) {
|
||||||
|
return error_value(E_D2DMS2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
s4 = v4->v_subtype;
|
||||||
|
if ((s2 | s3 | s4) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_D2DMS3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
freevalue(v4);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
v4->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
v4->v_subtype = s4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(degs, 360, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qthreesixty, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of degrees
|
||||||
|
*
|
||||||
|
* d = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - d;
|
||||||
|
* tmp_m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
* m = int(tmp_m);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
tmp_m = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
v3->v_num = qint(tmp_m);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* number of seconds
|
||||||
|
*
|
||||||
|
* tmp = tmp_m - m;
|
||||||
|
* free(tmp_m);
|
||||||
|
* s = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(tmp_m, v3->v_num);
|
||||||
|
qfree(tmp_m);
|
||||||
|
v4->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_d2dm(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4;
|
||||||
|
NUMBER *tmp;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3; /* to preserve subtypes of v2, v3 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 4) {
|
||||||
|
v4 = vals[3];
|
||||||
|
if (v4->v_type == V_ADDR) {
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
}
|
||||||
|
if (v4->v_type != V_NUM || qisfrac(v4->v_num) ||
|
||||||
|
qisneg(v4->v_num) || zge31b(v4->v_num->num)) {
|
||||||
|
return error_value(E_D2DM2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v4->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) {
|
||||||
|
return error_value(E_D2DM1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL)) {
|
||||||
|
return error_value(E_D2DM2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
if ((s2 | s3) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_D2DM3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(degs, 360, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qthreesixty, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of degrees
|
||||||
|
*
|
||||||
|
* d = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - d;
|
||||||
|
* m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
v3->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_g2gms(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4, *v5;
|
||||||
|
NUMBER *tmp, *tmp_m;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
v4 = vals[3];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 5) {
|
||||||
|
v5 = vals[4];
|
||||||
|
if (v5->v_type == V_ADDR) {
|
||||||
|
v5 = v5->v_addr;
|
||||||
|
}
|
||||||
|
if (v5->v_type != V_NUM || qisfrac(v5->v_num) ||
|
||||||
|
qisneg(v5->v_num) || zge31b(v5->v_num->num)) {
|
||||||
|
return error_value(E_G2GMS2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v5->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR ||
|
||||||
|
v4->v_type != V_ADDR) {
|
||||||
|
return error_value(E_G2GMS1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL) ||
|
||||||
|
(v4->v_type != V_NUM && v4->v_type != V_NULL)) {
|
||||||
|
return error_value(E_G2GMS2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
s4 = v4->v_subtype;
|
||||||
|
if ((s2 | s3 | s4) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_G2GMS3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
freevalue(v4);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
v4->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
v4->v_subtype = s4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(grads, 400, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qfourhundred, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of gradians
|
||||||
|
*
|
||||||
|
* g = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - g;
|
||||||
|
* tmp_m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
* m = int(tmp_m);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
tmp_m = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
v3->v_num = qint(tmp_m);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* number of seconds
|
||||||
|
*
|
||||||
|
* tmp = tmp_m - m;
|
||||||
|
* free(tmp_m);
|
||||||
|
* s = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(tmp_m, v3->v_num);
|
||||||
|
qfree(tmp_m);
|
||||||
|
v4->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_g2gm(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4;
|
||||||
|
NUMBER *tmp;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3; /* to preserve subtypes of v2, v3 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 4) {
|
||||||
|
v4 = vals[3];
|
||||||
|
if (v4->v_type == V_ADDR) {
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
}
|
||||||
|
if (v4->v_type != V_NUM || qisfrac(v4->v_num) ||
|
||||||
|
qisneg(v4->v_num) || zge31b(v4->v_num->num)) {
|
||||||
|
return error_value(E_G2GM2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v4->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) {
|
||||||
|
return error_value(E_G2GM1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL)) {
|
||||||
|
return error_value(E_G2GM2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
if ((s2 | s3) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_G2GM3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(grads, 400, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qfourhundred, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of gradians
|
||||||
|
*
|
||||||
|
* g = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - g;
|
||||||
|
* m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
v3->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_h2hms(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4, *v5;
|
||||||
|
NUMBER *tmp, *tmp_m;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
v4 = vals[3];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 5) {
|
||||||
|
v5 = vals[4];
|
||||||
|
if (v5->v_type == V_ADDR) {
|
||||||
|
v5 = v5->v_addr;
|
||||||
|
}
|
||||||
|
if (v5->v_type != V_NUM || qisfrac(v5->v_num) ||
|
||||||
|
qisneg(v5->v_num) || zge31b(v5->v_num->num)) {
|
||||||
|
return error_value(E_H2HMS2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v5->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR ||
|
||||||
|
v4->v_type != V_ADDR) {
|
||||||
|
return error_value(E_H2HMS1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL) ||
|
||||||
|
(v4->v_type != V_NUM && v4->v_type != V_NULL)) {
|
||||||
|
return error_value(E_H2HMS2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
s4 = v4->v_subtype;
|
||||||
|
if ((s2 | s3 | s4) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_H2HMS3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
freevalue(v4);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
v4->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
v4->v_subtype = s4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(hours, 24, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qtwentyfour, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of hours
|
||||||
|
*
|
||||||
|
* h = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - h;
|
||||||
|
* tmp_m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
* m = int(tmp_m);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
tmp_m = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
v3->v_num = qint(tmp_m);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* number of seconds
|
||||||
|
*
|
||||||
|
* tmp = tmp_m - m;
|
||||||
|
* free(tmp_m);
|
||||||
|
* s = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(tmp_m, v3->v_num);
|
||||||
|
qfree(tmp_m);
|
||||||
|
v4->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S_FUNC VALUE
|
||||||
|
f_h2hm(int count, VALUE **vals)
|
||||||
|
{
|
||||||
|
VALUE *v1, *v2, *v3, *v4;
|
||||||
|
NUMBER *tmp;
|
||||||
|
VALUE result;
|
||||||
|
long rnd;
|
||||||
|
short s2, s3; /* to preserve subtypes of v2, v3 */
|
||||||
|
|
||||||
|
/* collect required args */
|
||||||
|
v1 = vals[0];
|
||||||
|
v2 = vals[1];
|
||||||
|
v3 = vals[2];
|
||||||
|
|
||||||
|
/* determine rounding mode */
|
||||||
|
if (count == 4) {
|
||||||
|
v4 = vals[3];
|
||||||
|
if (v4->v_type == V_ADDR) {
|
||||||
|
v4 = v4->v_addr;
|
||||||
|
}
|
||||||
|
if (v4->v_type != V_NUM || qisfrac(v4->v_num) ||
|
||||||
|
qisneg(v4->v_num) || zge31b(v4->v_num->num)) {
|
||||||
|
return error_value(E_H2HM2);
|
||||||
|
}
|
||||||
|
rnd = qtoi(v4->v_num);
|
||||||
|
} else {
|
||||||
|
rnd = conf->quomod;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type parse args */
|
||||||
|
if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) {
|
||||||
|
return error_value(E_H2HM1);
|
||||||
|
}
|
||||||
|
if (v1->v_type == V_ADDR) {
|
||||||
|
v1 = v1->v_addr;
|
||||||
|
}
|
||||||
|
v2 = v2->v_addr;
|
||||||
|
v3 = v3->v_addr;
|
||||||
|
if (v1->v_type != V_NUM ||
|
||||||
|
(v2->v_type != V_NUM && v2->v_type != V_NULL) ||
|
||||||
|
(v3->v_type != V_NUM && v3->v_type != V_NULL)) {
|
||||||
|
return error_value(E_H2HM2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remember arg subtypes */
|
||||||
|
s2 = v2->v_subtype;
|
||||||
|
s3 = v3->v_subtype;
|
||||||
|
if ((s2 | s3) & V_NOASSIGNTO) {
|
||||||
|
return error_value(E_H2HM3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old args that will be modified */
|
||||||
|
freevalue(v2);
|
||||||
|
freevalue(v3);
|
||||||
|
|
||||||
|
/* set args that will be modified */
|
||||||
|
v2->v_type = V_NUM;
|
||||||
|
v3->v_type = V_NUM;
|
||||||
|
|
||||||
|
/* restore arg subtypes */
|
||||||
|
v2->v_subtype = s2;
|
||||||
|
v3->v_subtype = s3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calcuate the normalized return value
|
||||||
|
*
|
||||||
|
* return_value = mod(hours, 24, rnd);
|
||||||
|
*/
|
||||||
|
result.v_type = v1->v_type;
|
||||||
|
result.v_subtype = v1->v_subtype;
|
||||||
|
result.v_num = qmod(v1->v_num, &_qtwentyfour, rnd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of gradians
|
||||||
|
*
|
||||||
|
* h = int(return_value);
|
||||||
|
*/
|
||||||
|
v2->v_num = qint(result.v_num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer number of minutes
|
||||||
|
*
|
||||||
|
* tmp = return_value - h;
|
||||||
|
* m = tmp * 60;
|
||||||
|
* free(tmp);
|
||||||
|
*/
|
||||||
|
tmp = qsub(result.v_num, v2->v_num);
|
||||||
|
v3->v_num = qmuli(tmp, 60);
|
||||||
|
qfree(tmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the normalized value previously calculated
|
||||||
|
*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
S_FUNC VALUE
|
S_FUNC VALUE
|
||||||
f_mmin(VALUE *v1, VALUE *v2)
|
f_mmin(VALUE *v1, VALUE *v2)
|
||||||
{
|
{
|
||||||
@@ -8904,6 +9556,10 @@ STATIC CONST struct builtin builtins[] = {
|
|||||||
"date and time as string"},
|
"date and time as string"},
|
||||||
{"custom", 0, IN, 0, OP_NOP, 0, f_custom,
|
{"custom", 0, IN, 0, OP_NOP, 0, f_custom,
|
||||||
"custom builtin function interface"},
|
"custom builtin function interface"},
|
||||||
|
{"d2dm", 3, 4, FA, OP_NOP, 0, f_d2dm,
|
||||||
|
"convert a to b deg, c min, rounding type d\n"},
|
||||||
|
{"d2dms", 4, 5, FA, OP_NOP, 0, f_d2dms,
|
||||||
|
"convert a to b deg, c min, d sec, rounding type e\n"},
|
||||||
{"d2g", 1, 2, 0, OP_NOP, 0, f_d2g,
|
{"d2g", 1, 2, 0, OP_NOP, 0, f_d2g,
|
||||||
"convert degrees to gradians"},
|
"convert degrees to gradians"},
|
||||||
{"d2r", 1, 2, 0, OP_NOP, 0, f_d2r,
|
{"d2r", 1, 2, 0, OP_NOP, 0, f_d2r,
|
||||||
@@ -9020,6 +9676,10 @@ STATIC CONST struct builtin builtins[] = {
|
|||||||
"fractional part of value"},
|
"fractional part of value"},
|
||||||
{"g2d", 1, 2, 0, OP_NOP, 0, f_g2d,
|
{"g2d", 1, 2, 0, OP_NOP, 0, f_g2d,
|
||||||
"convert gradians to degrees"},
|
"convert gradians to degrees"},
|
||||||
|
{"g2gm", 3, 4, FA, OP_NOP, 0, f_g2gm,
|
||||||
|
"convert a to b grads, c min, rounding type d\n"},
|
||||||
|
{"g2gms", 4, 5, FA, OP_NOP, 0, f_g2gms,
|
||||||
|
"convert a to b grads, c min, d sec, rounding type e\n"},
|
||||||
{"g2r", 1, 2, 0, OP_NOP, 0, f_g2r,
|
{"g2r", 1, 2, 0, OP_NOP, 0, f_g2r,
|
||||||
"convert gradians to radians"},
|
"convert gradians to radians"},
|
||||||
{"gcd", 1, IN, 0, OP_NOP, f_gcd, 0,
|
{"gcd", 1, IN, 0, OP_NOP, f_gcd, 0,
|
||||||
@@ -9030,6 +9690,10 @@ STATIC CONST struct builtin builtins[] = {
|
|||||||
"Gudermannian function"},
|
"Gudermannian function"},
|
||||||
{"getenv", 1, 1, 0, OP_NOP, 0, f_getenv,
|
{"getenv", 1, 1, 0, OP_NOP, 0, f_getenv,
|
||||||
"value of environment variable (or NULL)"},
|
"value of environment variable (or NULL)"},
|
||||||
|
{"h2hm", 3, 4, FA, OP_NOP, 0, f_h2hm,
|
||||||
|
"convert a to b hours, c min, rounding type d\n"},
|
||||||
|
{"h2hms", 4, 5, FA, OP_NOP, 0, f_h2hms,
|
||||||
|
"convert a to b hours, c min, d sec, rounding type e\n"},
|
||||||
{"hash", 1, IN, 0, OP_NOP, 0, f_hash,
|
{"hash", 1, IN, 0, OP_NOP, 0, f_hash,
|
||||||
"return non-negative hash value for one or\n"
|
"return non-negative hash value for one or\n"
|
||||||
"\t\t\tmore values"},
|
"\t\t\tmore values"},
|
||||||
|
@@ -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 \
|
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
|
||||||
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
||||||
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
|
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 \
|
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
|
||||||
delete den dereference det digit digits display dp epsilon errcount \
|
d2dms d2g d2r delete den dereference det digit digits display dp \
|
||||||
errmax errno error estr euler eval exp fact factor fclose fcnt feof \
|
epsilon errcount errmax errno error estr euler eval exp fact factor \
|
||||||
ferror fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib \
|
fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
|
||||||
files floor fopen forall fpathopen fprintf fputc fputs fputstr frac \
|
fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
|
||||||
free freebernoulli freeeuler freeglobals freeredc freestatics frem \
|
fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||||
freopen fscan fscanf fseek fsize ftell g2d g2r gcd gcdrem gd \
|
freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
|
||||||
getenv hash head highbit hmean hnrmod hypot ilog ilog10 ilog2 im \
|
g2r gcd gcdrem gd getenv h2hm h2hms hash head highbit hmean hnrmod \
|
||||||
indices inputlevel insert int inverse iroot isalnum isalpha isassoc \
|
hypot ilog ilog10 ilog2 im indices inputlevel insert int inverse iroot \
|
||||||
isatty isblk iscntrl isconfig isdefined isdigit iserror iseven isfile \
|
isalnum isalpha isassoc isatty isblk iscntrl isconfig isdefined \
|
||||||
isgraph ishash isident isint islist islower ismat ismult isnull isnum \
|
isdigit iserror iseven isfile isgraph ishash isident isint islist \
|
||||||
isobj isobjtype isodd isprime isprint isptr ispunct isqrt isrand \
|
islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
|
||||||
israndom isreal isrel issimple isspace issq isstr istype isupper \
|
isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
|
||||||
isxdigit jacobi join lcm lcmfact lfactor ln log lowbit ltol makelist \
|
isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
|
||||||
matdim matfill matmax matmin matsum mattrace mattrans max memsize meq \
|
lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
|
||||||
min minv mmin mne mod modify name near newerror nextcand nextprime \
|
matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
|
||||||
norm null num oldvalue ord param perm pfact pi pix places pmod polar \
|
name near newerror nextcand nextprime norm null num oldvalue ord param \
|
||||||
poly pop popcnt pound power prevcand prevprime printf prompt protect \
|
perm pfact pi pix places pmod polar poly pop popcnt pound power \
|
||||||
ptest push putenv quo quomod r2d r2g rand randbit random randombit \
|
prevcand prevprime printf prompt protect ptest push putenv quo quomod \
|
||||||
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
|
r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
|
||||||
round rsearch runtime saveval scale scan scanf search sec sech seed \
|
rcsq re remove reverse rewind rm root round rsearch runtime saveval \
|
||||||
segment select sgn sha1 sin sinh size sizeof sleep sort sqrt srand \
|
scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
|
||||||
srandom ssq stoponerror str strcasecmp strcat strcmp strcpy strerror \
|
size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
|
||||||
strlen strncasecmp strncmp strncpy strpos strprintf strscan strscanf \
|
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
|
||||||
strtolower strtoupper substr sum swap system systime tail tan tanh \
|
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
|
||||||
test time trunc usertime version xor
|
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
|
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||||
# built from DETAIL_HELP files.
|
# built from DETAIL_HELP files.
|
||||||
|
117
help/d2dm
Normal file
117
help/d2dm
Normal 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
132
help/d2dms
Normal 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
117
help/g2gm
Normal 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
132
help/g2gms
Normal 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
117
help/h2hm
Normal 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
132
help/h2hms
Normal 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/
|
2
help/mod
2
help/mod
@@ -2,7 +2,7 @@ NAME
|
|||||||
mod - compute the remainder for an integer quotient
|
mod - compute the remainder for an integer quotient
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
mod(x, y, rnd)
|
mod(x, y [,rnd])
|
||||||
x % y
|
x % y
|
||||||
|
|
||||||
TYPES
|
TYPES
|
||||||
|
2
help/quo
2
help/quo
@@ -2,7 +2,7 @@ NAME
|
|||||||
quo - compute integer quotient of a value by a real number
|
quo - compute integer quotient of a value by a real number
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
quo(x, y, rnd) or x // y
|
quo(x, y [,rnd]) or x // y
|
||||||
|
|
||||||
TYPES
|
TYPES
|
||||||
If x is a matrix or list, the returned value is a matrix or list v of
|
If x is a matrix or list, the returned value is a matrix or list v of
|
||||||
|
@@ -26,6 +26,8 @@ EXAMPLE
|
|||||||
strcmp("abc", "abb") == 1
|
strcmp("abc", "abb") == 1
|
||||||
strcmp("abc", "abc") == 0
|
strcmp("abc", "abc") == 0
|
||||||
strcmp("abc", "abd") == -1
|
strcmp("abc", "abd") == -1
|
||||||
|
strcmp("desk", "Shabisky") == 1
|
||||||
|
strcmp("Shabisky", "desk") == -1
|
||||||
strcmp("abc\0", "abc") == 1
|
strcmp("abc\0", "abc") == 1
|
||||||
strcmp("a\0b", "a\0c") == -1
|
strcmp("a\0b", "a\0c") == -1
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ SEE ALSO
|
|||||||
strcat, strcpy, strerror, strlen, strncmp, strncpy, strpos,
|
strcat, strcpy, strerror, strlen, strncmp, strncpy, strpos,
|
||||||
strprintf, strscan, strscanf, substr
|
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
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
|
9
qmath.c
9
qmath.c
@@ -46,10 +46,17 @@ NUMBER _qneghalf_ = { { _oneval_, 1, 1 }, { _twoval_, 1, 0 }, 1, NULL };
|
|||||||
NUMBER _qonesqbase_ = { { _oneval_, 1, 0 }, { _sqbaseval_, 2, 0 }, 1, NULL };
|
NUMBER _qonesqbase_ = { { _oneval_, 1, 0 }, { _sqbaseval_, 2, 0 }, 1, NULL };
|
||||||
NUMBER _qtendivnine_ = { { _tenval_, 1, 0 }, { _nineval_, 1, 0 }, 1, NULL };
|
NUMBER _qtendivnine_ = { { _tenval_, 1, 0 }, { _nineval_, 1, 0 }, 1, NULL };
|
||||||
NUMBER _qninedivten_ = { { _nineval_, 1, 0 }, { _tenval_, 1, 0 }, 1, NULL };
|
NUMBER _qninedivten_ = { { _nineval_, 1, 0 }, { _tenval_, 1, 0 }, 1, NULL };
|
||||||
|
NUMBER _qthreesixty = { { _threesixtyval_, 1, 0 },
|
||||||
|
{ _oneval_, 1, 0 }, 1, NULL };
|
||||||
|
NUMBER _qfourhundred = { { _fourhundredval_, 1, 0 },
|
||||||
|
{ _oneval_, 1, 0 }, 1, NULL };
|
||||||
|
NUMBER _qtwentyfour = { { _twentyfourval_, 1, 0 },
|
||||||
|
{ _oneval_, 1, 0 }, 1, NULL };
|
||||||
|
|
||||||
NUMBER * initnumbs[INITCONSTCOUNT] = {&_qzero_, &_qone_, &_qtwo_, &_qthree_,
|
NUMBER * initnumbs[INITCONSTCOUNT] = {&_qzero_, &_qone_, &_qtwo_, &_qthree_,
|
||||||
&_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_,
|
&_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_,
|
||||||
&_qonesqbase_, &_qtendivnine_, &_qninedivten_ };
|
&_qonesqbase_, &_qtendivnine_, &_qninedivten_,
|
||||||
|
&_qthreesixty, &_qfourhundred, &_qtwentyfour };
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
3
qmath.h
3
qmath.h
@@ -35,7 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define INITCONSTCOUNT 12 /* number of initnumbs[] pre-defined constants */
|
#define INITCONSTCOUNT 15 /* number of initnumbs[] pre-defined constants */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rational arithmetic definitions.
|
* Rational arithmetic definitions.
|
||||||
@@ -276,6 +276,7 @@ static inline NUMBER* qlink(NUMBER* q) { if(q) { (q)->links++; } return q; }
|
|||||||
EXTERN NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_;
|
EXTERN NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_;
|
||||||
EXTERN NUMBER _qtwo_, _qthree_, _qfour_, _qten_;
|
EXTERN NUMBER _qtwo_, _qthree_, _qfour_, _qten_;
|
||||||
EXTERN NUMBER _qtendivnine_, _qninedivten_;
|
EXTERN NUMBER _qtendivnine_, _qninedivten_;
|
||||||
|
EXTERN NUMBER _qthreesixty, _qfourhundred, _qtwentyfour;
|
||||||
EXTERN NUMBER * initnumbs[];
|
EXTERN NUMBER * initnumbs[];
|
||||||
|
|
||||||
|
|
||||||
|
7
zmath.c
7
zmath.c
@@ -58,6 +58,9 @@ HALF _twentyval_[] = { 20 };
|
|||||||
HALF _sqbaseval_[] = { 0, 1 };
|
HALF _sqbaseval_[] = { 0, 1 };
|
||||||
HALF _pow4baseval_[] = { 0, 0, 1 };
|
HALF _pow4baseval_[] = { 0, 0, 1 };
|
||||||
HALF _pow8baseval_[] = { 0, 0, 0, 0, 1 };
|
HALF _pow8baseval_[] = { 0, 0, 0, 0, 1 };
|
||||||
|
HALF _threesixtyval_[] = { 360 };
|
||||||
|
HALF _fourhundredval_[] = { 400 };
|
||||||
|
HALF _twentyfourval_[] = { 24 };
|
||||||
|
|
||||||
ZVALUE zconst[] = {
|
ZVALUE zconst[] = {
|
||||||
{ _zeroval_, 1, 0}, { _oneval_, 1, 0}, { _twoval_, 1, 0},
|
{ _zeroval_, 1, 0}, { _oneval_, 1, 0}, { _twoval_, 1, 0},
|
||||||
@@ -66,7 +69,9 @@ ZVALUE zconst[] = {
|
|||||||
{ _nineval_, 1, 0}, { _tenval_, 1, 0}, { _elevenval_, 1, 0},
|
{ _nineval_, 1, 0}, { _tenval_, 1, 0}, { _elevenval_, 1, 0},
|
||||||
{ _twelveval_, 1, 0}, { _thirteenval_, 1, 0}, { _fourteenval_, 1, 0},
|
{ _twelveval_, 1, 0}, { _thirteenval_, 1, 0}, { _fourteenval_, 1, 0},
|
||||||
{ _fifteenval_, 1, 0}, { _sixteenval_, 1, 0}, { _seventeenval_, 1, 0},
|
{ _fifteenval_, 1, 0}, { _sixteenval_, 1, 0}, { _seventeenval_, 1, 0},
|
||||||
{ _eightteenval_, 1, 0}, { _nineteenval_, 1, 0}, { _twentyval_, 1, 0}
|
{ _eightteenval_, 1, 0}, { _nineteenval_, 1, 0}, { _twentyval_, 1, 0},
|
||||||
|
{ _threesixtyval_, 1, 0}, { _fourhundredval_, 1, 0},
|
||||||
|
{ _twentyfourval_, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
ZVALUE _zero_ = { _zeroval_, 1, 0};
|
ZVALUE _zero_ = { _zeroval_, 1, 0};
|
||||||
|
1
zmath.h
1
zmath.h
@@ -648,6 +648,7 @@ EXTERN HALF _tenval_[], _elevenval_[], _twelveval_[], _thirteenval_[];
|
|||||||
EXTERN HALF _fourteenval_[], _fifteenval_[];
|
EXTERN HALF _fourteenval_[], _fifteenval_[];
|
||||||
EXTERN HALF _sqbaseval_[];
|
EXTERN HALF _sqbaseval_[];
|
||||||
EXTERN HALF _fourthbaseval_[];
|
EXTERN HALF _fourthbaseval_[];
|
||||||
|
EXTERN HALF _threesixtyval_[], _fourhundredval_[], _twentyfourval_[];
|
||||||
|
|
||||||
EXTERN ZVALUE zconst[]; /* ZVALUE integers from 0 thru 15 */
|
EXTERN ZVALUE zconst[]; /* ZVALUE integers from 0 thru 15 */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user