mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +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:
20
cal/hms.cal
20
cal/hms.cal
@@ -352,24 +352,8 @@ define fixhms(a)
|
||||
quit "attempt to fix a non hms object";
|
||||
}
|
||||
|
||||
/* force minutes to be integral */
|
||||
a.min += frac(a.hour) * 60;
|
||||
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;
|
||||
/* use builtin h2hms function */
|
||||
h2hms(a.hour + a.min/60 + a.sec/3600, a.hour, a.min, a.sec),;
|
||||
|
||||
/* return normalized result */
|
||||
return a;
|
||||
|
Reference in New Issue
Block a user