mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e0cd9bb3db | ||
|
f0f6171354 | ||
|
94861cc6d2 | ||
|
286233e28f | ||
|
99ac7836aa | ||
|
6c0c8e0ef6 | ||
|
8aa5f140bf | ||
|
2fcb9a5995 | ||
|
8b018b697d | ||
|
0e269ecd67 | ||
|
a640bc4656 | ||
|
62a95499ef | ||
|
9e92d4a35a | ||
|
459c07b121 | ||
|
ada15fdabc | ||
|
d5de36841a | ||
|
cf419fb329 | ||
|
abf39b34b6 | ||
|
552252371f | ||
|
7570010a04 | ||
|
a9ee753dc6 | ||
|
ca5a81122a | ||
|
554cd97145 | ||
|
806606f284 | ||
|
7c0ebc5887 | ||
|
45665f94a7 |
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '41 1 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
182
CHANGES
182
CHANGES
@@ -36,6 +36,180 @@ The following are the changes from calc version 2.14.0.0 to date:
|
||||
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 want 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.
|
||||
|
||||
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.
|
||||
|
||||
Added builtin functions to convert between degrees, minutes and
|
||||
seconds and degrees under the config("mod") round rules:
|
||||
|
||||
dms2d(d, m, s [,rnd]) - convert deg, min, and secs to deg
|
||||
dm2d(d, m [,rnd]) - convert deg, min to deg
|
||||
|
||||
See help/dms2d and help/dm2d.
|
||||
|
||||
Example:
|
||||
|
||||
; print dms2d(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print dm2d(3601, -25.5594);
|
||||
0.57401
|
||||
|
||||
Added builtin functions to convert between gradians, minutes and
|
||||
seconds and gradians under the config("mod") round rules:
|
||||
|
||||
gms2g(g, m, s [,rnd]) - convert grad, min, and secs to grad
|
||||
gm2g(g, m [,rnd]) - convert grad and min to grad
|
||||
|
||||
See help/g2gms and help/g2gm.
|
||||
|
||||
Example:
|
||||
|
||||
; print gms2g(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print gm2g(4001, -25.5594);
|
||||
0.57401
|
||||
|
||||
Added builtin functions to convert between hours, minutes and
|
||||
seconds and hours under the config("mod") round rules:
|
||||
|
||||
hms2h(h, m, s [,rnd]) - convert hours, min, and secs to hours
|
||||
hm2h(h, m [,rnd]) - convert hours, min to hours
|
||||
|
||||
See help/hms2h and help/hm2h.
|
||||
|
||||
Example:
|
||||
|
||||
; print hms2h(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print hm2h(241, -25.5594);
|
||||
0.57401
|
||||
|
||||
Fixed typo in cal/statistics.cal thanks to a report by <GitHub user
|
||||
dennisaldea>.
|
||||
|
||||
Fixed an old Windoz pun in README.WINDOWS as requested by <GitHub
|
||||
user marcodegio>.
|
||||
|
||||
Fixed a really obscure bug in the internal initconstants()
|
||||
function of const.c that has been sitting for over 31 years!
|
||||
|
||||
We are amazed that nobody has encountered this bug before
|
||||
now. Nevertheless, our very extensive regression and
|
||||
multi-architecture testing found the bug. Now, after all
|
||||
those years, it is fixed.
|
||||
|
||||
Fixed issues identied by the default CodeUL GitHub security code scan:
|
||||
|
||||
Wrong type of arguments to printf in have_fpos_pos.c
|
||||
Multiplication result converted to larger type in zfunc.c
|
||||
|
||||
|
||||
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:
|
||||
|
||||
@@ -74,7 +248,7 @@ The following are the changes from calc version 2.13.0.0 to 2.13.0.0:
|
||||
|
||||
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 +284,7 @@ The following are the changes from calc version 2.13.0.0 to 2.13.0.0:
|
||||
#!/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 +1534,12 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
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:
|
||||
|
||||
|
@@ -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:
|
||||
|
6
Makefile
6
Makefile
@@ -35,6 +35,12 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
# Unfortunately due to the complex dependency issues between
|
||||
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
# is NOT recommended. Sorry.
|
||||
#
|
||||
.NOTPARALLEL:
|
||||
|
||||
# Try uname -s if the target was not already set on the make command line
|
||||
#
|
||||
ifeq ($(target),)
|
||||
|
@@ -59,6 +59,13 @@ SHELL= /bin/sh
|
||||
|
||||
|
||||
#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 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.14.0.0
|
||||
VERSION= 2.14.0.6
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
@@ -4831,7 +4838,7 @@ tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} ${MAKE_FILE}
|
||||
-${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 @@ clean: custom/Makefile
|
||||
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 @@ clean: custom/Makefile
|
||||
${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 @@ clobber: clean custom/Makefile
|
||||
${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 =-=-=-=-='
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Dear calc user on a Windoz based system,
|
||||
Dear calc user on a Windows based system,
|
||||
|
||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
See also the README file.
|
||||
|
21
SECURITY.md
Normal file
21
SECURITY.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 5.1.x | :white_check_mark: |
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use this section to tell people how to report a vulnerability.
|
||||
|
||||
Tell them where to go, how often they can expect to get an update on a
|
||||
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||
declined, etc.
|
20
cal/dms.cal
20
cal/dms.cal
@@ -352,24 +352,8 @@ define fixdms(a)
|
||||
quit "attempt to fix a non dms object";
|
||||
}
|
||||
|
||||
/* force minutes to be integral */
|
||||
a.min += frac(a.deg) * 60;
|
||||
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;
|
||||
/* use builtin d2dms function */
|
||||
d2dms(a.deg + a.min/60 + a.sec/3600, a.deg, a.min, a.sec),;
|
||||
|
||||
/* return normalized result */
|
||||
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";
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
405
cal/regress.cal
405
cal/regress.cal
@@ -775,7 +775,9 @@ print '016: parsed test_bignums()';
|
||||
/*
|
||||
* 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()
|
||||
{
|
||||
@@ -3400,9 +3402,11 @@ define test_trig()
|
||||
|
||||
print '3400: Beginning test_trig';
|
||||
|
||||
/* test 3401-3407 */
|
||||
tnum = test3400(1, 3401);
|
||||
vrfy(tnum == 3407, '3407: tnum == 3407');
|
||||
|
||||
print tnum: ': Ending test_trig';
|
||||
print '3438: Ending test_trig';
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
|
||||
@@ -8165,6 +8169,8 @@ ecnt = 211;
|
||||
* Test 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_functions2()
|
||||
{
|
||||
@@ -8278,6 +8284,401 @@ print;
|
||||
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');
|
||||
|
||||
/* dm2d */
|
||||
vrfy(dm2d(203, 325.5594) == 208.42599,
|
||||
'9214: dm2d(203, 325.5594) == 208.42599');
|
||||
vrfy(dm2d(3601, -25.5594) == 0.57401,
|
||||
'9215: dm2d(3601, -25.5594) == 0.57401');
|
||||
vrfy(dm2d(-923, -25.5594) == 156.57401,
|
||||
'9216: dm2d(-923, -25.5594) == 156.57401');
|
||||
vrfy(dm2d(203, 325.5594, 1) == -151.57401,
|
||||
'9217: dm2d(203, 325.5594, 1) == -151.57401');
|
||||
|
||||
vrfy(d2dm(dm2d(12, 20.16),d,m) == 12.336,
|
||||
'9218: d2dm(dm2d(12, 20.16),d,m) == 12.336');
|
||||
vrfy(d == 12,
|
||||
'9219: d == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9220: m == 20.16');
|
||||
|
||||
/* dms2d */
|
||||
vrfy(dms2d(12, 20, 44.16) == 12.3456,
|
||||
'9221: dms2d(12, 20, 44.16) == 12.3456');
|
||||
vrfy(dms2d(123.456, -345.68, 4.08) == 117.6958,
|
||||
'9222: dms2d(123.456, -345.68, 4.08) == 117.6958');
|
||||
vrfy(dms2d(-65, -40, -44.4) == 294.321,
|
||||
'9223: dms2d(-65, -40, -44.4) == 294.321');
|
||||
vrfy(dms2d(12, 20, 44.16, 1) == -347.6544,
|
||||
'9224: dms2d(12, 20, 44.16, 1) == -347.6544');
|
||||
|
||||
vrfy(d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456,
|
||||
'9225: d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456');
|
||||
vrfy(d == 13,
|
||||
'9226: d == 13');
|
||||
vrfy(m == 20,
|
||||
'9227: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9228: s == 44.16');
|
||||
|
||||
/* gm2g */
|
||||
vrfy(gm2g(203, 325.5594) == 208.42599,
|
||||
'9229: gm2g(203, 325.5594) == 208.42599');
|
||||
vrfy(gm2g(3601, -25.5594) == 0.57401,
|
||||
'9230: gm2g(3601, -25.5594) == 0.57401');
|
||||
vrfy(gm2g(-923, -25.5594) == 276.57401,
|
||||
'9231: gm2g(-923, -25.5594) == 276.57401');
|
||||
vrfy(gm2g(203, 325.5594, 1) == -191.57401,
|
||||
'9232: gm2g(203, 325.5594, 1) == -191.57401');
|
||||
|
||||
vrfy(g2gm(gm2g(12, 20.16),g,m) == 12.336,
|
||||
'9233: g2gm(gm2g(12, 20.16),g,m) == 12.336');
|
||||
vrfy(g == 12,
|
||||
'9234: g == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9235: m == 20.16');
|
||||
|
||||
/* gms2g */
|
||||
vrfy(gms2g(12, 20, 44.16) == 12.3456,
|
||||
'9236: gms2g(12, 20, 44.16) == 12.3456');
|
||||
vrfy(gms2g(123.456, -345.68, 4.08) == 117.6958,
|
||||
'9237: gms2g(123.456, -345.68, 4.08) == 117.6958');
|
||||
vrfy(gms2g(-65, -40, -44.4) == 334.321,
|
||||
'9238: gms2g(-65, -40, -44.4) == 334.321');
|
||||
vrfy(gms2g(12, 20, 44.16, 1) == -387.6544,
|
||||
'9239: gms2g(12, 20, 44.16, 1) == -387.6544');
|
||||
|
||||
vrfy(g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456,
|
||||
'9240: g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456');
|
||||
vrfy(g == 14,
|
||||
'9241: g == 14');
|
||||
vrfy(m == 20,
|
||||
'9242: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9243: s == 44.16');
|
||||
|
||||
/* hm2h */
|
||||
vrfy(hm2h(203, 325.5594) == 16.42599,
|
||||
'9244: hm2h(203, 325.5594) == 16.42599');
|
||||
vrfy(hm2h(241, -25.5594) == 0.57401,
|
||||
'9245: hm2h(241, -25.5594) == 0.57401');
|
||||
vrfy(hm2h(-923, -25.5594) == 12.57401,
|
||||
'9246: hm2h(-923, -25.5594) == 12.57401');
|
||||
vrfy(hm2h(203, 325.5594, 1) == -7.57401,
|
||||
'9247: hm2h(203, 325.5594, 1) == -7.57401');
|
||||
|
||||
vrfy(h2hm(hm2h(12, 20.16),h,m) == 12.336,
|
||||
'9248: h2hm(hm2h(12, 20.16),h,m) == 12.336');
|
||||
vrfy(h == 12,
|
||||
'9249: h == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9250: m == 20.16');
|
||||
|
||||
/* hms2h */
|
||||
vrfy(hms2h(12, 20, 44.16) == 12.3456,
|
||||
'9251: hms2h(12, 20, 44.16) == 12.3456');
|
||||
vrfy(hms2h(123.456, -345.68, 4.08) == 21.6958,
|
||||
'9252: hms2h(123.456, -345.68, 4.08) == 21.6958');
|
||||
vrfy(hms2h(-65, -40, -44.4) == 6.321,
|
||||
'9253: hms2h(-65, -40, -44.4) == 6.321');
|
||||
vrfy(hms2h(12, 20, 44.16, 1) == -11.6544,
|
||||
'9254: hms2h(12, 20, 44.16, 1) == -11.6544');
|
||||
|
||||
vrfy(h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456,
|
||||
'9255: h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456');
|
||||
vrfy(h == 15,
|
||||
'9256: h == 15');
|
||||
vrfy(m == 20,
|
||||
'9257: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9258: s == 44.16');
|
||||
|
||||
print '9259: Ending test_functions3';
|
||||
}
|
||||
print;
|
||||
print '9100: parsed test_functions3()';
|
||||
print;
|
||||
return test_functions3();
|
||||
|
||||
|
||||
/*
|
||||
* read various calc resource files
|
||||
*
|
||||
|
@@ -371,7 +371,7 @@ define normalcdf(x,mu,sigma){
|
||||
|
||||
define probit(p){
|
||||
if(p<0 || p > 1) return newerror("probit: p out of domain 0<=p<=1");
|
||||
return sqrt(2)*ervinv(2*p-1);
|
||||
return sqrt(2)*erfinv(2*p-1);
|
||||
}
|
||||
|
||||
define normalcdfinv(p,mu,sigma){
|
||||
|
48
calcerr.tbl
48
calcerr.tbl
@@ -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,49 @@ E_ATANH3 Invalid value for calculating atan
|
||||
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
|
||||
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_D2DMS4 Invalid rounding arg 5 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_D2DM4 Invalid rounding arg 4 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 g2gms
|
||||
E_G2GMS4 Invalid rounding arg 5 for g2gms
|
||||
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 g2gm
|
||||
E_G2GM4 Invalid rounding arg 4 for g2gm
|
||||
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_H2HMS4 Invalid rounding arg 5 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
|
||||
E_H2HM4 Invalid rounding arg 4 for h2hm
|
||||
E_DMS2D1 Non-real-number aarguments 1, 2 or 3 for dms2d
|
||||
E_DMS2D2 Invalid rounding arg 4 for dms2d
|
||||
E_DM2D1 Non-real-number aarguments 1 or 2 for dm2d
|
||||
E_DM2D2 Invalid rounding arg 4 for dm2d
|
||||
E_GMS2G1 Non-real-number aarguments 1, 2 or 3 for gms2g
|
||||
E_GMS2G2 Invalid rounding arg 4 for gms2g
|
||||
E_GM2G1 Non-real-number aarguments 1 or 2 for gm2g
|
||||
E_GM2G2 Invalid rounding arg 4 for gm2g
|
||||
E_HMS2H1 Non-real-number aarguments 1, 2 or 3 for hms2h
|
||||
E_HMS2H2 Invalid rounding arg 4 for hms2h
|
||||
E_HM2H1 Non-real-number aarguments 1 or 2 for hm2h
|
||||
E_HM2H2 Invalid rounding arg 4 for hm2h
|
||||
|
13
const.c
13
const.c
@@ -44,16 +44,16 @@ initconstants(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
consttable = (NUMBER **) malloc(sizeof(NUMBER *) * CONSTALLOCSIZE);
|
||||
consttable = (NUMBER **) calloc(sizeof(NUMBER *), CONSTALLOCSIZE);
|
||||
if (consttable == NULL) {
|
||||
math_error("Unable to allocate constant table");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
for (i = 0; i < INITCONSTCOUNT; i++)
|
||||
for (i = 0; initnumbs[i] != NULL; i++) {
|
||||
consttable[i] = initnumbs[i];
|
||||
consttable[INITCONSTCOUNT] = NULL; /* firewall */
|
||||
constcount = INITCONSTCOUNT;
|
||||
constavail = CONSTALLOCSIZE - INITCONSTCOUNT;
|
||||
}
|
||||
constcount = i-1;
|
||||
constavail = CONSTALLOCSIZE - constcount;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,9 @@ addqconstant(NUMBER *q)
|
||||
tp = consttable;
|
||||
for (index = 0; index < constcount; index++, tp++) {
|
||||
t = *tp;
|
||||
if (t == NULL) { /* paranoia */
|
||||
break;
|
||||
}
|
||||
if (t->links == 0) {
|
||||
if (!havefirst) {
|
||||
havefirst = TRUE;
|
||||
|
@@ -145,6 +145,13 @@ CCBAN= -UUNBAN
|
||||
|
||||
|
||||
#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 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.14.0.0
|
||||
VERSION= 2.14.0.6
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
|
@@ -145,6 +145,13 @@ CCBAN= -UUNBAN
|
||||
|
||||
|
||||
#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 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.14.0.0
|
||||
VERSION= 2.14.0.6
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
|
@@ -56,8 +56,8 @@ main(void)
|
||||
printf("#define FPOS_POS_BITS %d\n", FPOS_POS_BITS);
|
||||
printf("#define FPOS_POS_LEN %d\n", int(FPOS_POS_BITS/8));
|
||||
# else
|
||||
printf("#define FPOS_POS_BITS %d\n", sizeof(pos.__pos)*8);
|
||||
printf("#define FPOS_POS_LEN %d\n", sizeof(pos.__pos));
|
||||
printf("#define FPOS_POS_BITS %lu\n", sizeof(pos.__pos)*8);
|
||||
printf("#define FPOS_POS_LEN %lu\n", sizeof(pos.__pos));
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
3
help.c
3
help.c
@@ -83,6 +83,9 @@ STATIC struct help_alias {
|
||||
{"show", "command"},
|
||||
{"stdlib", "resource"},
|
||||
{"question", "questions"},
|
||||
{"dm2d", "dms2d"},
|
||||
{"gm2g", "gms2g"},
|
||||
{"hm2d", "hms2d"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@@ -356,7 +356,7 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
#
|
||||
# Please use:
|
||||
#
|
||||
# make detail_help_list
|
||||
# make clobber >/dev/null && make detail_help_list
|
||||
#
|
||||
# to keep this list in nice sorted order.
|
||||
#
|
||||
@@ -364,14 +364,15 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
|
||||
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
||||
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime 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 \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
|
||||
d2dms d2g d2r delete den dereference det digit digits display dms2d dp \
|
||||
epsilon errcount errmax errno error estr euler eval exp fact factor \
|
||||
fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
|
||||
fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
|
||||
fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||
freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
|
||||
g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \
|
||||
hms2h 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 \
|
||||
@@ -381,11 +382,11 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
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 \
|
||||
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 \
|
||||
@@ -730,7 +731,7 @@ distlist: ${DISTLIST}
|
||||
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
|
||||
|
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/
|
55
help/d2g
Normal file
55
help/d2g
Normal file
@@ -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/
|
59
help/d2r
Normal file
59
help/d2r
Normal file
@@ -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/
|
84
help/dms2d
Normal file
84
help/dms2d
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
dm2d, dms2d - convert degrees, minutes, and seconds to degrees
|
||||
|
||||
SYNOPSIS
|
||||
dm2d(d, m [,rnd])
|
||||
dms2d(d, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
d real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return degrees
|
||||
|
||||
DESCRIPTION
|
||||
Convert degrees, m minutes, and s seconds returning degrees.
|
||||
|
||||
The return value in degrees, is quivalent to the following:
|
||||
|
||||
mod(d + m/60 + s/3600, 360, rnd);
|
||||
|
||||
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).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The dm2d(d, m, rnd) builtin is an alias for dms2d(d, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print dm2d(203, 325.5594);
|
||||
208.42599
|
||||
; print dm2d(3601, -25.5594);
|
||||
0.57401
|
||||
; print dm2d(-923, -25.5594);
|
||||
156.57401
|
||||
|
||||
; print dms2d(12, 20, 44.16);
|
||||
12.3456
|
||||
; print dms2d(123.456, -345.68, 4.08);
|
||||
117.6958
|
||||
; print dms2d(-65, -40, -44.4);
|
||||
294.321
|
||||
|
||||
; print dm2d(203, 325.5594, 1);
|
||||
-151.57401
|
||||
; print dms2d(12, 20, 44.16, 1);
|
||||
-347.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, 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/
|
55
help/g2d
Normal file
55
help/g2d
Normal file
@@ -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/
|
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/
|
59
help/g2r
Normal file
59
help/g2r
Normal file
@@ -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/
|
84
help/gms2g
Normal file
84
help/gms2g
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
gm2g, gms2g - convert gradians, minutes, and seconds to gradians
|
||||
|
||||
SYNOPSIS
|
||||
gm2g(d, m [,rnd])
|
||||
gms2g(d, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
d real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return gradians
|
||||
|
||||
DESCRIPTION
|
||||
Convert gradians, m minutes, and s seconds returning gradians.
|
||||
|
||||
The return value in gradians, is quivalent to the following:
|
||||
|
||||
mod(d + m/60 + s/4000, 400, rnd);
|
||||
|
||||
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).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The gm2g(d, m, rnd) builtin is an alias for gms2g(d, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print gm2g(203, 325.5594);
|
||||
208.42599
|
||||
; print gm2g(4001, -25.5594);
|
||||
0.57401
|
||||
; print gm2g(-923, -25.5594);
|
||||
276.57401
|
||||
|
||||
; print gms2g(12, 20, 44.16);
|
||||
12.3456
|
||||
; print gms2g(123.456, -345.68, 4.08);
|
||||
117.6958
|
||||
; print gms2g(-65, -40, -44.4);
|
||||
334.321
|
||||
|
||||
; print gm2g(203, 325.5594, 1);
|
||||
-191.57401
|
||||
; print gms2g(12, 20, 44.16, 1);
|
||||
-387.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, 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/
|
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/
|
84
help/hms2h
Normal file
84
help/hms2h
Normal file
@@ -0,0 +1,84 @@
|
||||
NAME
|
||||
hm2h, hms2h - convert hours, minutes, and seconds to hours
|
||||
|
||||
SYNOPSIS
|
||||
hm2h(h, m [,rnd])
|
||||
hms2h(h, m, s [,rnd])
|
||||
|
||||
TYPES
|
||||
h real
|
||||
m real
|
||||
s real (defauls to 0)
|
||||
rnd nonnegative integer, defaults to config("mod")
|
||||
|
||||
return hours
|
||||
|
||||
DESCRIPTION
|
||||
Convert hours, m minutes, and s seconds returning hours.
|
||||
|
||||
The return value in hours, is quivalent to the following:
|
||||
|
||||
mod(h + m/60 + s/3600, 24, rnd);
|
||||
|
||||
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).
|
||||
|
||||
A missing rnd defaults to config("mod").
|
||||
For more information on the effects of rnd, see "help mod".
|
||||
|
||||
The hm2h(h, m, rnd) builtin is an alias for hms2h(h, m, 0, rnd).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; print hm2h(203, 325.5594);
|
||||
16.42599
|
||||
; print hm2h(241, -25.5594);
|
||||
0.57401
|
||||
; print hm2h(-923, -25.5594);
|
||||
12.57401
|
||||
|
||||
; print hms2h(12, 20, 44.16);
|
||||
12.3456
|
||||
; print hms2h(123.456, -345.68, 4.08);
|
||||
21.6958
|
||||
; print hms2h(-65, -40, -44.4);
|
||||
6.321
|
||||
|
||||
; print hm2h(203, 325.5594, 1);
|
||||
-7.57401
|
||||
; print hms2h(12, 20, 44.16, 1);
|
||||
-11.6544
|
||||
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, d2dm, 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/
|
2
help/mod
2
help/mod
@@ -2,7 +2,7 @@ NAME
|
||||
mod - compute the remainder for an integer quotient
|
||||
|
||||
SYNOPSIS
|
||||
mod(x, y, rnd)
|
||||
mod(x, y [,rnd])
|
||||
x % y
|
||||
|
||||
TYPES
|
||||
|
2
help/quo
2
help/quo
@@ -2,7 +2,7 @@ NAME
|
||||
quo - compute integer quotient of a value by a real number
|
||||
|
||||
SYNOPSIS
|
||||
quo(x, y, rnd) or x // y
|
||||
quo(x, y [,rnd]) or x // y
|
||||
|
||||
TYPES
|
||||
If x is a matrix or list, the returned value is a matrix or list v of
|
||||
|
57
help/r2d
Normal file
57
help/r2d
Normal file
@@ -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/
|
57
help/r2g
Normal file
57
help/r2g
Normal file
@@ -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/
|
@@ -26,6 +26,8 @@ EXAMPLE
|
||||
strcmp("abc", "abb") == 1
|
||||
strcmp("abc", "abc") == 0
|
||||
strcmp("abc", "abd") == -1
|
||||
strcmp("desk", "Shabisky") == 1
|
||||
strcmp("Shabisky", "desk") == -1
|
||||
strcmp("abc\0", "abc") == 1
|
||||
strcmp("a\0b", "a\0c") == -1
|
||||
|
||||
@@ -39,7 +41,7 @@ SEE ALSO
|
||||
strcat, strcpy, strerror, strlen, strncmp, strncpy, strpos,
|
||||
strprintf, strscan, strscanf, substr
|
||||
|
||||
## Copyright (C) 2006 Ernest Bowen
|
||||
## Copyright (C) 2006,2021 Ernest Bowen
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -228,7 +228,7 @@ Unexpected
|
||||
|
||||
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 @@ Unexpected
|
||||
; 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
|
||||
|
18
qmath.c
18
qmath.c
@@ -44,9 +44,21 @@ NUMBER _qnegone_ = { { _oneval_, 1, 1 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||
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 _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_,
|
||||
&_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_};
|
||||
NUMBER * initnumbs[] = {&_qzero_, &_qone_, &_qtwo_, &_qthree_,
|
||||
&_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_,
|
||||
&_qonesqbase_, &_qtendivnine_, &_qninedivten_,
|
||||
&_qthreesixty, &_qfourhundred, &_qtwentyfour,
|
||||
NULL /* must be last */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@@ -1478,7 +1490,7 @@ shownumbers(void)
|
||||
printf("Index Links Digits Value\n");
|
||||
printf("----- ----- ------ -----\n");
|
||||
|
||||
for (i = 0, k = 0; i < INITCONSTCOUNT; i++) {
|
||||
for (i = 0, k = 0; initnumbs[i] != NULL; i++) {
|
||||
count++;
|
||||
vp = initnumbs[i];
|
||||
printf("%6ld %4ld ", k++, vp->links);
|
||||
|
8
qmath.h
8
qmath.h
@@ -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,8 +35,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define INITCONSTCOUNT 9 /* number of initnumbs[] pre-defined constants */
|
||||
|
||||
/*
|
||||
* Rational arithmetic definitions.
|
||||
*/
|
||||
@@ -213,6 +211,8 @@ E_FUNC NUMBER *qacsch(NUMBER *q, NUMBER *epsilon);
|
||||
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 +273,8 @@ static inline NUMBER* qlink(NUMBER* q) { if(q) { (q)->links++; } return q; }
|
||||
*/
|
||||
EXTERN NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_;
|
||||
EXTERN NUMBER _qtwo_, _qthree_, _qfour_, _qten_;
|
||||
EXTERN NUMBER _qtendivnine_, _qninedivten_;
|
||||
EXTERN NUMBER _qthreesixty, _qfourhundred, _qtwentyfour;
|
||||
EXTERN NUMBER * initnumbs[];
|
||||
|
||||
|
||||
|
147
qtrans.c
147
qtrans.c
@@ -47,7 +47,40 @@ NUMBER _qlge_ = { { _qlgenum_, 1, 0 }, { _qlgeden_, 1, 0 }, 1, NULL };
|
||||
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 @@ qpi(NUMBER *epsilon)
|
||||
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 @@ qpi(NUMBER *epsilon)
|
||||
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.
|
||||
|
@@ -54,7 +54,7 @@ static char *program;
|
||||
#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 6 /* minor software version level */
|
||||
|
||||
|
||||
/*
|
||||
|
4
zfunc.c
4
zfunc.c
@@ -1034,7 +1034,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
|
||||
}
|
||||
needw = FALSE;
|
||||
}
|
||||
g = *a0 * w;
|
||||
g = (FULL) (*a0 * w);
|
||||
if (h < BASEB) {
|
||||
g &= (1 << h) - 1;
|
||||
} else {
|
||||
@@ -1044,7 +1044,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
|
||||
g = 1;
|
||||
}
|
||||
} else {
|
||||
g = (HALF) *a0 * w;
|
||||
g = (FULL) (*a0 * w);
|
||||
}
|
||||
a = a0;
|
||||
b = b0;
|
||||
|
7
zmath.c
7
zmath.c
@@ -58,6 +58,9 @@ HALF _twentyval_[] = { 20 };
|
||||
HALF _sqbaseval_[] = { 0, 1 };
|
||||
HALF _pow4baseval_[] = { 0, 0, 1 };
|
||||
HALF _pow8baseval_[] = { 0, 0, 0, 0, 1 };
|
||||
HALF _threesixtyval_[] = { 360 };
|
||||
HALF _fourhundredval_[] = { 400 };
|
||||
HALF _twentyfourval_[] = { 24 };
|
||||
|
||||
ZVALUE zconst[] = {
|
||||
{ _zeroval_, 1, 0}, { _oneval_, 1, 0}, { _twoval_, 1, 0},
|
||||
@@ -66,7 +69,9 @@ ZVALUE zconst[] = {
|
||||
{ _nineval_, 1, 0}, { _tenval_, 1, 0}, { _elevenval_, 1, 0},
|
||||
{ _twelveval_, 1, 0}, { _thirteenval_, 1, 0}, { _fourteenval_, 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};
|
||||
|
1
zmath.h
1
zmath.h
@@ -648,6 +648,7 @@ EXTERN HALF _tenval_[], _elevenval_[], _twelveval_[], _thirteenval_[];
|
||||
EXTERN HALF _fourteenval_[], _fifteenval_[];
|
||||
EXTERN HALF _sqbaseval_[];
|
||||
EXTERN HALF _fourthbaseval_[];
|
||||
EXTERN HALF _threesixtyval_[], _fourhundredval_[], _twentyfourval_[];
|
||||
|
||||
EXTERN ZVALUE zconst[]; /* ZVALUE integers from 0 thru 15 */
|
||||
|
||||
|
Reference in New Issue
Block a user