Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package calc for openSUSE:Factory checked in at 2021-09-09 23:07:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/calc (Old) and /work/SRC/openSUSE:Factory/.calc.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "calc" Thu Sep 9 23:07:33 2021 rev:27 rq:917672 version:2.14.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/calc/calc.changes 2021-09-07 21:22:23.321373111 +0200 +++ /work/SRC/openSUSE:Factory/.calc.new.1899/calc.changes 2021-09-09 23:07:57.796860142 +0200 @@ -1,0 +2,19 @@ +Thu Sep 9 07:06:50 UTC 2021 - Michael Vetter <[email protected]> + +- Update to 2.14.0.2: + * The clean and clobber makefile rules no longer list custom/Makefile + as a dependency. + * Unfortunately due to the complex dependency issues between + Makefile, Makefile.ship and custom/Makefile, parallel GNU make + is NOT recommended. + * Fixed a few typos in CHANGES. + * As a side note: We stayed v2.13.x was kept for only a short time. + The move to 2.14.x was motivated by non-compatible changes due to + the default order of CALCRC, plus some new builtin functions. + * More changes are likely, so we might see another v2.14.0.x release + before things are declared "recommended stable". + * Not that we wan to discourage people from trying v2.14.0, you should + try it. We just want things to become stable and well field tested + before we reach the "recommended stable" release state. + +------------------------------------------------------------------- Old: ---- calc-2.14.0.0.tar.bz2 New: ---- calc-2.14.0.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ calc.spec ++++++ --- /var/tmp/diff_new_pack.fN0P3p/_old 2021-09-09 23:07:58.296860723 +0200 +++ /var/tmp/diff_new_pack.fN0P3p/_new 2021-09-09 23:07:58.300860728 +0200 @@ -19,7 +19,7 @@ %define soname 2 %define libname libcalc%{soname} Name: calc -Version: 2.14.0.0 +Version: 2.14.0.2 Release: 0 Summary: C-style arbitrary precision calculator License: LGPL-2.1-only ++++++ calc-2.14.0.0.tar.bz2 -> calc-2.14.0.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/CHANGES new/calc-2.14.0.2/CHANGES --- old/calc-2.14.0.0/CHANGES 2021-09-07 08:05:16.000000000 +0200 +++ new/calc-2.14.0.2/CHANGES 2021-09-08 23:31:20.000000000 +0200 @@ -36,6 +36,52 @@ a call to base2(1000) would make calc unstable and likely to dump core. + Added builtin functions to convert between degrees, radians + and gradians: + + d2r(deg) - given degrees returns radians + g2r(grad) - given gradians returns radians + + r2d(rad) - given radians returns degrees + g2d(grad) - given gradians returns degrees + + r2g(rad) - given radians returns gradians + d2g(deg) - given degrees returns gradians + + Add 6 functions take a 2nd optional epsilon argument. + For d2r(deg, ep), r2d(rad, ep), the optional 2nd epsilon argument controls + the precision of the internal constant pi/180. + For g2r(grad, ep), r2g(rad, ep), the optional 2nd epsilon argument controls + the precision of the internal constant pi/200. + The optional 2nd argument is ignored by g2d(grad, ep) and d2g(deg, ep). + + The clean and clobber makefile rules no longer list custom/Makefile + as a dependecy. + + Unfortunately due to the complex dependency issues between + Makefile, Makefile.ship and custom/Makefile, parallel GNU make + is NOT recommended. Sorry (tm Canada) :) + + The clean and clobber makefile rules no longer list custom/Makefile + as a dependency. + + Unfortunately due to the complex dependency issues between + Makefile, Makefile.ship and custom/Makefile, parallel GNU make + is NOT recommended. Sorry (tm Canada) :) + + Fixed a few typos in CHANGES. + + As a side note: We stayed v2.13.x was kept for only a short time. + The move to 2.14.x was motivated by non-compatible changes due to + the default order of CALCRC, plus some new builtin functions. + + More changes are likely, so we might see another v2.14.0.x release + before things are declared "recommended stable". + + Not that we wan to discourage people from trying v2.14.0, you should + try it. We just want things to become stable and well field tested + before we reach the "recommended stable" release state. + The following are the changes from calc version 2.13.0.1 to 2.13.0.1: @@ -74,7 +120,7 @@ Fixed typo (missing quotes) in the env rule. - Fixed intendation problem in CHANGES. + Fixed indentation problem in CHANGES. Combined 2.12.9.1 changes into the 2.12.8.2 to 2.12.9.0 range, and thus renamed the range to 2.12.8.2 to 2.12.9.1. @@ -110,7 +156,7 @@ #!/usr/local/bin/calc -f ... - It is common that -q be usde with a calc script, so assuming the + It is common that -q be used with a calc script, so assuming the same /usr/local/bin/calc path: #!/usr/local/bin/calc -q -f @@ -1360,12 +1406,12 @@ The custom/Makefile is now constructed from 3 parts: custom/Makefile.head, the host target section in Makefile, and the custom/Makefile.tail. - The top level Makefile and the custom/Makefile require a GNU Make + The top level Makefile and the custom/Makefile require a GNU make (such as gmake) or an equivalently advanced make. On many targets, the default make is sufficient. On FreeBSD for example, one must use gmake instead of make. - If your target system does not have GNU Make (or equivalent), then + If your target system does not have GNU make (or equivalent), then you should try using the Makefile.simple and custom/Makefile.simple files: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/HOWTO.INSTALL new/calc-2.14.0.2/HOWTO.INSTALL --- old/calc-2.14.0.0/HOWTO.INSTALL 2021-04-17 08:23:22.000000000 +0200 +++ new/calc-2.14.0.2/HOWTO.INSTALL 2021-09-08 01:28:51.000000000 +0200 @@ -2,6 +2,14 @@ IMPORTANT: Please see the section at the bottom of this file for some important information on Makefiles used in calc. +################################################################### +# IMPORTANT: DO NOT run GNU make in parallel mode!!! # +################################################################### +# Unfortunately due to the complex dependency issues between # +# Makefile, Makefile.ship and custom/Makefile, parallel GNU make # +# is NOT recommended. Sorry (tm Canada) :) # +################################################################### + Installing calc from the bzip2-ed tarball in 4 easy steps: (0) If your platform supports i686 RPMs, you may want to go to: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/Makefile new/calc-2.14.0.2/Makefile --- old/calc-2.14.0.0/Makefile 2021-09-07 04:27:44.000000000 +0200 +++ new/calc-2.14.0.2/Makefile 2021-09-08 23:37:34.000000000 +0200 @@ -59,6 +59,13 @@ #if 0 /* start of skip for non-Gnu makefiles */ + +# Unfortunately due to the complex dependency issues between +# Makefile, Makefile.ship and custom/Makefile, parallel GNU make +# is NOT recommended. Sorry. +# +.NOTPARALLEL: + ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# ############################################################################## @@ -1198,7 +1205,7 @@ # The default calc versions # -VERSION= 2.14.0.0 +VERSION= 2.14.0.2 # Names of shared libraries with versions # @@ -4831,7 +4838,7 @@ -${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \ ${GREP} -v 'Duplicate entry|Second entry ignored' -clean: custom/Makefile +clean: ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${RM} -f ${LIBOBJS} ${RM} -f ${CALCOBJS} @@ -4852,6 +4859,7 @@ cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' + ${MAKE} custom/Makefile cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${Q} echo remove files that are obsolete @@ -4861,7 +4869,7 @@ ${RM} -f win32dll.h have_malloc.h math_error.h string.h string.c ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' -clobber: clean custom/Makefile +clobber: clean ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${RM} -f ${SAMPLE_TARGETS} ${RM} -f ${SAMPLE_STATIC_TARGETS} @@ -4898,6 +4906,7 @@ ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' -${RM} -f custom/all; \ + ${MAKE} custom/Makefile; \ cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} $@ ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/Makefile.simple new/calc-2.14.0.2/Makefile.simple --- old/calc-2.14.0.0/Makefile.simple 2021-09-07 08:27:19.000000000 +0200 +++ new/calc-2.14.0.2/Makefile.simple 2021-09-08 23:41:16.000000000 +0200 @@ -1117,7 +1117,7 @@ # The default calc versions # -VERSION= 2.14.0.0 +VERSION= 2.14.0.2 # Names of shared libraries with versions # @@ -4140,7 +4140,7 @@ -${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \ ${GREP} -v 'Duplicate entry|Second entry ignored' -clean: custom/Makefile +clean: ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${RM} -f ${LIBOBJS} ${RM} -f ${CALCOBJS} @@ -4161,6 +4161,7 @@ cd custom; ${MAKE} -f Makefile.simple ${CUSTOM_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' + ${MAKE} custom/Makefile cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${Q} echo remove files that are obsolete @@ -4170,7 +4171,7 @@ ${RM} -f win32dll.h have_malloc.h math_error.h string.h string.c ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' -clobber: clean custom/Makefile +clobber: clean ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${RM} -f ${SAMPLE_TARGETS} ${RM} -f ${SAMPLE_STATIC_TARGETS} @@ -4207,6 +4208,7 @@ ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' -${RM} -f custom/all; \ + ${MAKE} custom/Makefile; \ cd custom; ${MAKE} -f Makefile.simple ${CUSTOM_PASSDOWN} $@ ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/cal/regress.cal new/calc-2.14.0.2/cal/regress.cal --- old/calc-2.14.0.0/cal/regress.cal 2021-09-07 04:20:42.000000000 +0200 +++ new/calc-2.14.0.2/cal/regress.cal 2021-09-07 20:58:11.000000000 +0200 @@ -3400,9 +3400,79 @@ print '3400: Beginning test_trig'; + /* test 3401-3407 */ tnum = test3400(1, 3401); + vrfy(tnum == 3407, '3407: tnum == 3407'); - print tnum: ': Ending test_trig'; + /* 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 '051: parsed test_trig()'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/calcerr.tbl new/calc-2.14.0.2/calcerr.tbl --- old/calc-2.14.0.0/calcerr.tbl 2018-09-30 22:31:49.000000000 +0200 +++ new/calc-2.14.0.2/calcerr.tbl 2021-09-07 16:52:34.000000000 +0200 @@ -1,7 +1,7 @@ # # calcerr - error codes and messages # -# Copyright (C) 1999-2006 Ernest Bowen +# Copyright (C) 1999-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 @@ -496,3 +496,13 @@ E_ACOTH3 Invalid value for calculating acot E_ASECH3 Invalid value for calculating asec E_ACSCH3 Invalid value for calculating acsc +E_D2R1 Bad epsilon for converting degrees to radians +E_D2R2 Bad first argument converting degrees to radians +E_R2D1 Bad epsilon for converting radians to degrees +E_R2D2 Bad first argument converting radians to degrees +E_G2R1 Bad epsilon for converting gradians to radians +E_G2R2 Bad first argument converting gradians to radians +E_R2G1 Bad epsilon for converting radians to gradians +E_R2G2 Bad first argument converting radians to gradians +E_D2G1 Bad first argument converting degrees to gradians +E_G2D1 Bad first argument converting gradians to degrees diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/custom/Makefile new/calc-2.14.0.2/custom/Makefile --- old/calc-2.14.0.0/custom/Makefile 2021-09-07 08:26:36.000000000 +0200 +++ new/calc-2.14.0.2/custom/Makefile 2021-09-08 23:40:32.000000000 +0200 @@ -145,6 +145,13 @@ #if 0 /* start of skip for non-Gnu makefiles */ + +# Unfortunately due to the complex dependency issues between +# Makefile, Makefile.ship and custom/Makefile, parallel GNU make +# is NOT recommended. Sorry. +# +.NOTPARALLEL: + ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# ############################################################################## @@ -489,7 +496,7 @@ # The default calc versions # -VERSION= 2.14.0.0 +VERSION= 2.14.0.2 # Names of shared libraries with versions # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/custom/Makefile.head new/calc-2.14.0.2/custom/Makefile.head --- old/calc-2.14.0.0/custom/Makefile.head 2021-09-07 04:27:44.000000000 +0200 +++ new/calc-2.14.0.2/custom/Makefile.head 2021-09-08 23:37:34.000000000 +0200 @@ -145,6 +145,13 @@ #if 0 /* start of skip for non-Gnu makefiles */ + +# Unfortunately due to the complex dependency issues between +# Makefile, Makefile.ship and custom/Makefile, parallel GNU make +# is NOT recommended. Sorry. +# +.NOTPARALLEL: + ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# ############################################################################## @@ -489,7 +496,7 @@ # The default calc versions # -VERSION= 2.14.0.0 +VERSION= 2.14.0.2 # Names of shared libraries with versions # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/custom/Makefile.simple new/calc-2.14.0.2/custom/Makefile.simple --- old/calc-2.14.0.0/custom/Makefile.simple 2021-09-07 08:27:19.000000000 +0200 +++ new/calc-2.14.0.2/custom/Makefile.simple 2021-09-08 23:41:16.000000000 +0200 @@ -460,7 +460,7 @@ # The default calc versions # -VERSION= 2.14.0.0 +VERSION= 2.14.0.2 # Names of shared libraries with versions # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/func.c new/calc-2.14.0.2/func.c --- old/calc-2.14.0.0/func.c 2021-09-07 04:06:43.000000000 +0200 +++ new/calc-2.14.0.2/func.c 2021-09-07 16:58:28.000000000 +0200 @@ -2181,6 +2181,240 @@ } +/* + * f_d2r - convert degrees to radians + */ +S_FUNC VALUE +f_d2r(int count, VALUE **vals) +{ + VALUE result; + NUMBER *eps; + NUMBER *pidiv180; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* firewall */ + eps = conf->epsilon; + if (count == 2) { + if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) + return error_value(E_D2R1); + eps = vals[1]->v_num; + } + + /* calculate argument * (pi/180) */ + switch (vals[0]->v_type) { + case V_NUM: + pidiv180 = qpidiv180(eps); + result.v_num = qmul(vals[0]->v_num, pidiv180); + result.v_type = V_NUM; + qfree(pidiv180); + break; + case V_COM: + pidiv180 = qpidiv180(eps); + result.v_com = c_mulq(vals[0]->v_com, pidiv180); + result.v_type = V_COM; + qfree(pidiv180); + break; + default: + return error_value(E_D2R2); + } + return result; +} + + +/* + * f_r2d - convert radians to degrees + */ +S_FUNC VALUE +f_r2d(int count, VALUE **vals) +{ + VALUE result; + NUMBER *eps; + NUMBER *pidiv180; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* firewall */ + eps = conf->epsilon; + if (count == 2) { + if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) + return error_value(E_R2D1); + eps = vals[1]->v_num; + } + + /* calculate argument / (pi/180) */ + switch (vals[0]->v_type) { + case V_NUM: + pidiv180 = qpidiv180(eps); + result.v_num = qqdiv(vals[0]->v_num, pidiv180); + result.v_type = V_NUM; + qfree(pidiv180); + break; + case V_COM: + pidiv180 = qpidiv180(eps); + result.v_com = c_divq(vals[0]->v_com, pidiv180); + result.v_type = V_COM; + qfree(pidiv180); + break; + default: + return error_value(E_R2D2); + } + return result; +} + + +/* + * f_d2r - convert gradians to radians + */ +S_FUNC VALUE +f_g2r(int count, VALUE **vals) +{ + VALUE result; + NUMBER *eps; + NUMBER *pidiv200; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* firewall */ + eps = conf->epsilon; + if (count == 2) { + if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) + return error_value(E_G2R1); + eps = vals[1]->v_num; + } + + /* calculate argument * (pi/200) */ + switch (vals[0]->v_type) { + case V_NUM: + pidiv200 = qpidiv200(eps); + result.v_num = qmul(vals[0]->v_num, pidiv200); + result.v_type = V_NUM; + qfree(pidiv200); + break; + case V_COM: + pidiv200 = qpidiv200(eps); + result.v_com = c_mulq(vals[0]->v_com, pidiv200); + result.v_type = V_COM; + qfree(pidiv200); + break; + default: + return error_value(E_G2R2); + } + return result; +} + + +/* + * f_r2g - convert radians to gradians + */ +S_FUNC VALUE +f_r2g(int count, VALUE **vals) +{ + VALUE result; + NUMBER *eps; + NUMBER *pidiv200; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* firewall */ + eps = conf->epsilon; + if (count == 2) { + if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) + return error_value(E_R2G1); + eps = vals[1]->v_num; + } + + /* calculate argument / (pi/200) */ + switch (vals[0]->v_type) { + case V_NUM: + pidiv200 = qpidiv200(eps); + result.v_num = qqdiv(vals[0]->v_num, pidiv200); + result.v_type = V_NUM; + qfree(pidiv200); + break; + case V_COM: + pidiv200 = qpidiv200(eps); + result.v_com = c_divq(vals[0]->v_com, pidiv200); + result.v_type = V_COM; + qfree(pidiv200); + break; + default: + return error_value(E_R2G2); + } + return result; +} + + +/* + * f_d2g - convert degrees to gradians + * + * NOTE: The epsilon (vals[1]->v_num) argument is ignored. + */ +/*ARGSUSED*/ +S_FUNC VALUE +f_d2g(int UNUSED(count), VALUE **vals) +{ + VALUE result; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* NOTE: the epsilon (vals[1]->v_num) argument is ignored */ + + /* calculate argument * (10/9) */ + switch (vals[0]->v_type) { + case V_NUM: + result.v_num = qmul(vals[0]->v_num, &_qtendivnine_); + result.v_type = V_NUM; + break; + case V_COM: + result.v_com = c_mulq(vals[0]->v_com, &_qtendivnine_); + result.v_type = V_COM; + break; + default: + return error_value(E_D2G1); + } + return result; +} + + +/* + * f_g2d - convert gradians to degrees + * + * NOTE: The epsilon (vals[1]->v_num) argument is ignored. + */ +/*ARGSUSED*/ +S_FUNC VALUE +f_g2d(int UNUSED(count), VALUE **vals) +{ + VALUE result; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* NOTE: the epsilon (vals[1]->v_num) argument is ignored */ + + /* calculate argument * (9/10) */ + switch (vals[0]->v_type) { + case V_NUM: + result.v_num = qmul(vals[0]->v_num, &_qninedivten_); + result.v_type = V_NUM; + break; + case V_COM: + result.v_com = c_mulq(vals[0]->v_com, &_qninedivten_); + result.v_type = V_COM; + break; + default: + return error_value(E_G2D1); + } + return result; +} + + S_FUNC VALUE f_sin(int count, VALUE **vals) { @@ -8670,6 +8904,10 @@ "date and time as string"}, {"custom", 0, IN, 0, OP_NOP, 0, f_custom, "custom builtin function interface"}, + {"d2g", 1, 2, 0, OP_NOP, 0, f_d2g, + "convert degrees to gradians"}, + {"d2r", 1, 2, 0, OP_NOP, 0, f_d2r, + "convert degrees to radians"}, {"delete", 2, 2, FA, OP_NOP, 0, f_listdelete, "delete element from list a at position b"}, {"den", 1, 1, 0, OP_DENOMINATOR, qden, 0, @@ -8780,6 +9018,10 @@ "return the file position"}, {"frac", 1, 1, 0, OP_FRAC, qfrac, 0, "fractional part of value"}, + {"g2d", 1, 2, 0, OP_NOP, 0, f_g2d, + "convert gradians to degrees"}, + {"g2r", 1, 2, 0, OP_NOP, 0, f_g2r, + "convert gradians to radians"}, {"gcd", 1, IN, 0, OP_NOP, f_gcd, 0, "greatest common divisor"}, {"gcdrem", 2, 2, 0, OP_NOP, qgcdrem, 0, @@ -9027,6 +9269,10 @@ {"quomod", 4, 5, FA, OP_NOP, 0, f_quomod, "set c and d to quotient and remainder of a\n" "\t\t\tdivided by b"}, + {"r2d", 1, 2, 0, OP_NOP, 0, f_r2d, + "convert radians to degrees"}, + {"r2g", 1, 2, 0, OP_NOP, 0, f_r2g, + "convert radians to gradians"}, {"rand", 0, 2, 0, OP_NOP, f_rand, 0, "additive 55 random number [0,2^64), [0,a), or [a,b)"}, {"randbit", 0, 1, 0, OP_NOP, f_randbit, 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/Makefile new/calc-2.14.0.2/help/Makefile --- old/calc-2.14.0.0/help/Makefile 2021-04-09 21:36:34.000000000 +0200 +++ new/calc-2.14.0.2/help/Makefile 2021-09-07 22:40:05.000000000 +0200 @@ -356,7 +356,7 @@ # # Please use: # -# make detail_help_list +# make clobber >/dev/null && make detail_help_list # # to keep this list in nice sorted order. # @@ -364,32 +364,32 @@ 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 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 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 questions \ - quo quomod 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 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 # This list is of files that are clones of DETAIL_HELP files. They are # built from DETAIL_HELP files. @@ -730,7 +730,7 @@ if [ X"$$i" != X"/dev/null" ]; then \ echo help/$$i; \ fi; \ - done | LANG=C ${SORT} + done | fgrep -v '.bak' | LANG=C ${SORT} distdir: ${Q} echo help diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/d2g new/calc-2.14.0.2/help/d2g --- old/calc-2.14.0.0/help/d2g 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/d2g 2021-09-07 22:02:36.000000000 +0200 @@ -0,0 +1,55 @@ +NAME + d2g - convert degrees to gradians + +SYNOPSIS + d2g(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x degrees, return the equivalent number of gradians. + + The eps argument is ignored. + +EXAMPLE + ; print d2g(45), d2g(180), d2g(30) + 50 200 ~33.33333333333333333333 + + ; print d2g(3i+2) + ~2.22222222222222222222+~3.33333333333333333333i + +LIMITS + none + +LINK LIBRARY + none + +SEE ALSO + d2r, r2d, g2r, r2g, g2d, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/d2r new/calc-2.14.0.2/help/d2r --- old/calc-2.14.0.0/help/d2r 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/d2r 2021-09-07 22:02:24.000000000 +0200 @@ -0,0 +1,59 @@ +NAME + d2r - convert degrees to radians + +SYNOPSIS + d2r(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x degrees, return the equivalent number of radians. + + The eps controls the precision of the calculated internal + constant pi / 180. + +EXAMPLE + ; print d2r(45), d2r(180), d2r(30) + ~0.78539816339744830962 3.14159265358979323846 ~0.52359877559829887308 + + ; print d2r(3i+2) + ~0.03490658503988659154+~0.05235987755982988731i + + ; print sin(d2r(30)), cos(d2r(60)), tan(d2r(45)) + 0.5 0.5 1 + +LIMITS + eps > 0 + +LINK LIBRARY + NUMBER *qpidiv180(NUMBER *eps) + +SEE ALSO + r2d, g2r, r2g, d2g, g2d, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/g2d new/calc-2.14.0.2/help/g2d --- old/calc-2.14.0.0/help/g2d 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/g2d 2021-09-07 22:06:02.000000000 +0200 @@ -0,0 +1,55 @@ +NAME + g2d - convert gradians to degrees + +SYNOPSIS + g2d(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x gradians, return the equivalent number of degrees. + + The eps argument is ignored. + +EXAMPLE + ; print g2d(50), g2d(200), g2d(30) + 45 180 27 + + ; print g2d(3i+2) + 1.8+2.7i + +LIMITS + none + +LINK LIBRARY + none + +SEE ALSO + d2r, r2d, g2r, r2g, d2g, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/g2r new/calc-2.14.0.2/help/g2r --- old/calc-2.14.0.0/help/g2r 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/g2r 2021-09-07 22:02:31.000000000 +0200 @@ -0,0 +1,59 @@ +NAME + g2r - convert gradians to radians + +SYNOPSIS + g2r(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x gradians, return the equivalent number of radians. + + The eps controls the precision of the calculated internal + constant pi / 200. + +EXAMPLE + ; print g2r(50), g2r(200), g2r(50) + ~0.78539816339744830962 3.14159265358979323846 ~0.78539816339744830962 + + ; print g2r(3i+2) + ~0.03141592653589793238+~0.04712388980384689858i + + ; print sin(g2r(100/3)), cos(g2r(200/3)), tan(g2r(50)) + 0.5 0.5 1 + +LIMITS + eps > 0 + +LINK LIBRARY + NUMBER *qpidiv200(NUMBER *eps) + +SEE ALSO + d2r, r2d, r2g, d2g, g2d, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/questions new/calc-2.14.0.2/help/questions --- old/calc-2.14.0.0/help/questions 2021-09-07 08:27:18.000000000 +0200 +++ new/calc-2.14.0.2/help/questions 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -If you have a simple general question about calc, send Email to: - - calc-quest-mail at asthe dot com - - NOTE: Remove spaces and replace 'at' with @, and 'dot' with . - -PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line: - - calc question - -You may add additional words to your subject line. - -IMPORTANT: If your Email doesn't contain the above phrase, - then we WILL NOT SEE your Email. - -PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line! - -Suggestion: - - From time to time, the Email address and Subject SPECIAL PHRASE - may change so verify you have the current info by visiting: - - http://www.isthe.com/chongo/tech/comp/calc/calc-question.html - -Please limit your questions to general questions about calc. We -cannot go into great detail in our answers, nor can we do your -homework, nor can we do much more than answer short general questions -about calc. - -Please be patient as we cannot always respond to Email messages quickly. - -=-= - -## 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/02/10 00:15:05 -## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/r2d new/calc-2.14.0.2/help/r2d --- old/calc-2.14.0.0/help/r2d 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/r2d 2021-09-07 22:02:15.000000000 +0200 @@ -0,0 +1,57 @@ +NAME + r2d - convert radians to degrees + +SYNOPSIS + r2d(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x radians, return the equivalent number of degrees. + + The eps controls the precision of the calculated internal + constant pi / 180. + +EXAMPLE + ; pi = pi(1e-20) + ; print r2d(pi), r2d(pi/3), r2d(2*pi) + 180 60 360 + + ; print r2d(pi+4i), r2d(pi/3 + 1i*pi), r2d(pi/5 + 5i*pi) + 180+~229.18311805232928350739i 60+180, 36+900i + +LIMITS + eps > 0 + +LINK LIBRARY + NUMBER *qpidiv180(NUMBER *eps) + +SEE ALSO + d2r, g2r, r2g, d2g, g2d, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/r2g new/calc-2.14.0.2/help/r2g --- old/calc-2.14.0.0/help/r2g 1970-01-01 01:00:00.000000000 +0100 +++ new/calc-2.14.0.2/help/r2g 2021-09-07 22:02:42.000000000 +0200 @@ -0,0 +1,57 @@ +NAME + r2g - convert radians to gradians + +SYNOPSIS + r2g(x [,eps]) + +TYPES + x number (real or complex) + eps nonzero real, defaults to epsilon() + + return number + +DESCRIPTION + Given x radians, return the equivalent number of gradians. + + The eps controls the precision of the calculated internal + constant pi / 200. + +EXAMPLE + ; pi = pi() + ; print r2g(pi), r2g(pi/3), r2g(2*pi) + 200 ~66.66666666666666666667 400 + + ; print r2g(pi+4i), r2g(pi/4 + 1i*pi), r2g(pi/5 + 5i*pi) + 200+~254.64790894703253723043i 50+200i 40+1000i + +LIMITS + eps > 0 + +LINK LIBRARY + NUMBER *qpidiv200(NUMBER *eps) + +SEE ALSO + d2r, r2d, g2r, d2g, g2d, + sin, cos, tan, sec, csc, cot, epsilon + +## 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/07 12:04:28 +## 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/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/help/unexpected new/calc-2.14.0.2/help/unexpected --- old/calc-2.14.0.0/help/unexpected 2021-03-01 21:01:28.000000000 +0100 +++ new/calc-2.14.0.2/help/unexpected 2021-09-07 22:24:21.000000000 +0200 @@ -228,7 +228,7 @@ 1<<8/2 - evalues to 128, not 16, because <<8 is performed before the /2. + evaluates to 128, not 16, because <<8 is performed before the /2. &A[0] and A are different things in calc @@ -529,6 +529,34 @@ ; help fclose + trig functions use only radians + =============================== + + Some might be surprised to discover that all of the trigonometric in calc: + + sin, cos, tan, sec, csc, cot + asin, acos, atan, asec, acsc, acot + + work in only radians. + + Calc as builtin functions to convert between degrees, radians and gradians: + + d2r(deg) - given degrees returns radians + g2r(grad) - given gradians returns radians + + r2d(rad) - given radians returns degrees + g2d(grad) - given gradians returns degrees + + r2g(rad) - given radians returns gradians + d2g(deg) - given degrees returns gradians + + For example, if you want to take the sin of 30 degrees, convert + the 30 degrees into radians and pass the result to sin(): + + ; print sin(d2r(30)) + 0.5 + + ## Copyright (C) 1999-2007,2014,2017,2021 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/qmath.c new/calc-2.14.0.2/qmath.c --- old/calc-2.14.0.0/qmath.c 2021-03-08 19:58:40.000000000 +0100 +++ new/calc-2.14.0.2/qmath.c 2021-09-07 16:46:13.000000000 +0200 @@ -44,9 +44,12 @@ NUMBER _qonehalf_ = { { _oneval_, 1, 0 }, { _twoval_, 1, 0 }, 1, NULL }; NUMBER _qneghalf_ = { { _oneval_, 1, 1 }, { _twoval_, 1, 0 }, 1, NULL }; NUMBER _qonesqbase_ = { { _oneval_, 1, 0 }, { _sqbaseval_, 2, 0 }, 1, NULL }; +NUMBER _qtendivnine_ = { { _tenval_, 1, 0 }, { _nineval_, 1, 0 }, 1, NULL }; +NUMBER _qninedivten_ = { { _nineval_, 1, 0 }, { _tenval_, 1, 0 }, 1, NULL }; NUMBER * initnumbs[INITCONSTCOUNT] = {&_qzero_, &_qone_, &_qtwo_, &_qthree_, - &_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_}; + &_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_, + &_qonesqbase_, &_qtendivnine_, &_qninedivten_ }; /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/qmath.h new/calc-2.14.0.2/qmath.h --- old/calc-2.14.0.0/qmath.h 2021-03-08 19:58:40.000000000 +0100 +++ new/calc-2.14.0.2/qmath.h 2021-09-07 16:47:19.000000000 +0200 @@ -1,7 +1,7 @@ /* * qmath - declarations for extended precision rational arithmetic * - * Copyright (C) 1999-2007,2014 David I. Bell + * Copyright (C) 1999-2007,2014,2021 David I. Bell * * 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 @@ -35,7 +35,7 @@ #endif -#define INITCONSTCOUNT 9 /* number of initnumbs[] pre-defined constants */ +#define INITCONSTCOUNT 12 /* number of initnumbs[] pre-defined constants */ /* * Rational arithmetic definitions. @@ -213,6 +213,8 @@ E_FUNC NUMBER *qacoth(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qlegtoleg(NUMBER *q, NUMBER *epsilon, BOOL wantneg); E_FUNC NUMBER *qpi(NUMBER *epsilon); +E_FUNC NUMBER *qpidiv180(NUMBER *epsilon); +E_FUNC NUMBER *qpidiv200(NUMBER *epsilon); E_FUNC NUMBER *qcatalan(NUMBER *); E_FUNC NUMBER *qbern(ZVALUE z); E_FUNC void qfreebern(void); @@ -273,6 +275,7 @@ */ EXTERN NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_; EXTERN NUMBER _qtwo_, _qthree_, _qfour_, _qten_; +EXTERN NUMBER _qtendivnine_, _qninedivten_; EXTERN NUMBER * initnumbs[]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/qtrans.c new/calc-2.14.0.2/qtrans.c --- old/calc-2.14.0.0/qtrans.c 2021-03-08 19:58:40.000000000 +0100 +++ new/calc-2.14.0.2/qtrans.c 2021-09-07 15:55:54.000000000 +0200 @@ -47,7 +47,40 @@ STATIC NUMBER *ln_10 = NULL; STATIC NUMBER *ln_10_epsilon = NULL; -STATIC NUMBER *pivalue[2]; +/* + * cache pi + * + * pivalue[LAST_PI_EPSILON] - last epsilon used to calculate pi + * pivalue[LAST_PI_VALUE] - last calculated pi + * given pivalue[LAST_PI_EPSILON] epsilon + * pivalue[LAST_PI_DIV_180_EPSILON] - last epsilon used to calculate pi/180 + * pivalue[LAST_PI_DIV_180_VALUE] - last calculated pi/180 given + * pivalue[LAST_PI_DIV_180_EPSILON] epsilon + * pivalue[LAST_PI_DIV_200_EPSILON] - last epsilon used to calculate pi/200 + * pivalue[LAST_PI_DIV_200_VALUE] - last calculated pi/200 given + * pivalue[LAST_PI_DIV_200_EPSILON] epsilon + */ +enum pi_cache { + LAST_PI_EPSILON = 0, + LAST_PI_VALUE, + LAST_PI_DIV_180_EPSILON, + LAST_PI_DIV_180_VALUE, + LAST_PI_DIV_200_EPSILON, + LAST_PI_DIV_200_VALUE, + PI_CACHE_LEN /* must be last */ +}; +STATIC NUMBER *pivalue[PI_CACHE_LEN] = { + NULL, /* LAST_PI_EPSILON */ + NULL, /* LAST_PI_VALUE */ + NULL, /* LAST_PI_DIV_180_EPSILON */ + NULL, /* LAST_PI_DIV_180_VALUE */ + NULL, /* LAST_PI_DIV_200_EPSILON */ + NULL, /* LAST_PI_DIV_200_VALUE */ +}; + +/* + * other static function decls + */ STATIC NUMBER *qexprel(NUMBER *q, long bitnum); /* @@ -725,16 +758,25 @@ long bits; /* needed number of bits of precision */ long t; + /* firewall */ if (qiszero(epsilon)) { math_error("zero epsilon value for pi"); /*NOTREACHED*/ } - if (epsilon == pivalue[0]) - return qlink(pivalue[1]); - if (pivalue[0]) { - qfree(pivalue[0]); - qfree(pivalue[1]); + + /* use pi cache if epsilon marches, else flush if needed */ + if (pivalue[LAST_PI_EPSILON] != NULL && + pivalue[LAST_PI_VALUE] != NULL && + epsilon == pivalue[LAST_PI_EPSILON]) { + return qlink(pivalue[LAST_PI_VALUE]); + } + if (pivalue[LAST_PI_EPSILON] != NULL) { + qfree(pivalue[LAST_PI_EPSILON]); } + if (pivalue[LAST_PI_VALUE] != NULL) { + qfree(pivalue[LAST_PI_VALUE]); + } + bits = -qilog2(epsilon) + 4; if (bits < 4) bits = 4; @@ -768,11 +810,100 @@ zfree(sum); r = qmappr(t1, epsilon, 24L); qfree(t1); - pivalue[0] = qlink(epsilon); - pivalue[1] = qlink(r); + pivalue[LAST_PI_EPSILON] = qlink(epsilon); + pivalue[LAST_PI_VALUE] = qlink(r); return r; } + +/* + * qpidiv180 - calcucalte pi / 180 + * + * This function returns pi/180 as used to covert between radians and degrees. + */ +NUMBER * +qpidiv180(NUMBER *epsilon) +{ + NUMBER *pi, *pidiv180; + + /* firewall */ + if (qiszero(epsilon)) { + math_error("zero epsilon value for qpidiv180"); + /*NOTREACHED*/ + } + + /* use pi/180 cache if epsilon marches, else flush if needed */ + if (pivalue[LAST_PI_DIV_180_EPSILON] != NULL && + pivalue[LAST_PI_DIV_180_VALUE] != NULL && + epsilon == pivalue[LAST_PI_DIV_180_EPSILON]) { + return qlink(pivalue[LAST_PI_DIV_180_VALUE]); + } + if (pivalue[LAST_PI_DIV_180_EPSILON] != NULL) { + qfree(pivalue[LAST_PI_DIV_180_EPSILON]); + } + if (pivalue[LAST_PI_DIV_180_VALUE] != NULL) { + qfree(pivalue[LAST_PI_DIV_180_VALUE]); + } + + /* let qpi() returned cached pi or calculate new as needed */ + pi = qpi(epsilon); + + /* calculate pi/180 */ + pidiv180 = qdivi(pi, 180); + + /* cache epsilon and pi/180 */ + pivalue[LAST_PI_DIV_180_EPSILON] = qlink(epsilon); + pivalue[LAST_PI_DIV_180_VALUE] = qlink(pidiv180); + + /* return pi/180 */ + return pidiv180; +} + + +/* + * qpidiv200 - calcucalte pi / 200 + * + * This function returns pi/200 as used to covert between radians and gradians. + */ +NUMBER * +qpidiv200(NUMBER *epsilon) +{ + NUMBER *pi, *pidiv200; + + /* firewall */ + if (qiszero(epsilon)) { + math_error("zero epsilon value for qpidiv200"); + /*NOTREACHED*/ + } + + /* use pi/200 cache if epsilon marches, else flush if needed */ + if (pivalue[LAST_PI_DIV_200_EPSILON] != NULL && + pivalue[LAST_PI_DIV_200_VALUE] != NULL && + epsilon == pivalue[LAST_PI_DIV_200_EPSILON]) { + return qlink(pivalue[LAST_PI_DIV_200_VALUE]); + } + if (pivalue[LAST_PI_DIV_200_EPSILON] != NULL) { + qfree(pivalue[LAST_PI_DIV_200_EPSILON]); + } + if (pivalue[LAST_PI_DIV_200_VALUE] != NULL) { + qfree(pivalue[LAST_PI_DIV_200_VALUE]); + } + + /* let qpi() returned cached pi or calculate new as needed */ + pi = qpi(epsilon); + + /* calculate pi/200 */ + pidiv200 = qdivi(pi, 200); + + /* cache epsilon and pi/200 */ + pivalue[LAST_PI_DIV_200_EPSILON] = qlink(epsilon); + pivalue[LAST_PI_DIV_200_VALUE] = qlink(pidiv200); + + /* return pi/200 */ + return pidiv200; +} + + /* * Calculate the exponential function to the nearest or next to nearest * multiple of the positive number epsilon. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/version.c new/calc-2.14.0.2/version.c --- old/calc-2.14.0.0/version.c 2021-09-07 04:27:35.000000000 +0200 +++ new/calc-2.14.0.2/version.c 2021-09-08 23:34:29.000000000 +0200 @@ -54,7 +54,7 @@ #define MAJOR_VER 2 /* major library version */ #define MINOR_VER 14 /* minor library version */ #define MAJOR_PATCH 0 /* major software version level */ -#define MINOR_PATCH 0 /* minor software version level */ +#define MINOR_PATCH 2 /* minor software version level */ /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/win32/calcerr.c new/calc-2.14.0.2/win32/calcerr.c --- old/calc-2.14.0.0/win32/calcerr.c 2021-09-07 08:27:18.000000000 +0200 +++ new/calc-2.14.0.2/win32/calcerr.c 2021-09-08 23:41:15.000000000 +0200 @@ -474,5 +474,15 @@ "Invalid value for calculating acot", "Invalid value for calculating asec", "Invalid value for calculating acsc", + "Bad epsilon for converting degrees to radians", + "Bad first argument converting degrees to radians", + "Bad epsilon for converting radians to degrees", + "Bad first argument converting radians to degrees", + "Bad epsilon for converting gradians to radians", + "Bad first argument converting gradians to radians", + "Bad epsilon for converting radians to gradians", + "Bad first argument converting radians to gradians", + "Bad first argument converting degrees to gradians", + "Bad first argument converting gradians to degrees", NULL }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/calc-2.14.0.0/win32/calcerr.h new/calc-2.14.0.2/win32/calcerr.h --- old/calc-2.14.0.0/win32/calcerr.h 2021-09-07 08:27:16.000000000 +0200 +++ new/calc-2.14.0.2/win32/calcerr.h 2021-09-08 23:41:13.000000000 +0200 @@ -469,9 +469,19 @@ #define E_ACOTH3 10456 /* Invalid value for calculating acot */ #define E_ASECH3 10457 /* Invalid value for calculating asec */ #define E_ACSCH3 10458 /* Invalid value for calculating acsc */ +#define E_D2R1 10459 /* Bad epsilon for converting degrees to radians */ +#define E_D2R2 10460 /* Bad first argument converting degrees to radians */ +#define E_R2D1 10461 /* Bad epsilon for converting radians to degrees */ +#define E_R2D2 10462 /* Bad first argument converting radians to degrees */ +#define E_G2R1 10463 /* Bad epsilon for converting gradians to radians */ +#define E_G2R2 10464 /* Bad first argument converting gradians to radians */ +#define E_R2G1 10465 /* Bad epsilon for converting radians to gradians */ +#define E_R2G2 10466 /* Bad first argument converting radians to gradians */ +#define E_D2G1 10467 /* Bad first argument converting degrees to gradians */ +#define E_G2D1 10468 /* Bad first argument converting gradians to degrees */ -#define E__HIGHEST 10458 /* highest calc error */ -#define E__COUNT 458 /* number of calc errors */ +#define E__HIGHEST 10468 /* highest calc error */ +#define E__COUNT 468 /* number of calc errors */ #define E_USERDEF 20000 /* base of user defined errors */ /* names of calc error values */
