Compare commits

...

32 Commits

Author SHA1 Message Date
Landon Curt Noll
fde724aa2d Release v2.14.0.9
The following are the changes in this release:

    Due to issues with clang and Apple Silicon, ARCH_CFLAGS is now,
    by default, empty:

	ARCH_CFLAGS=

    If you want to use, say, -march=native, then either change
    the Makefile or make with:

	make all ARCH_CFLAGS='-march=native'

    Added arch and hardware as GNU Makefile computed values.
    As with ${target}, ${arch} and ${hardware} is computed by uname:

	target: uname -a
	arch: uname -p
	hardware: uname -m

    Fixed compiling calc on Apple Silicon with homebrew.  On Apple
    Silicon, HomeBrew installs on into a different location.  The
    Makefile checks if ${hardware} is arm64 and adjusts the location
    of libraries such as readline and history accordingly.
2021-11-24 01:35:01 -08:00
Landon Curt Noll
e411a3e6bf Trim long lines in Makefile 2021-11-24 01:33:00 -08:00
Landon Curt Noll
7db81649b0 Fixed compiling for Apple Silicon arm64 w/HomeBrew 2021-11-24 01:25:49 -08:00
Landon Curt Noll
08fe6f13f4 Release v2.14.0.8
The following are the changes in this release:

    Identical to v2.14.0.7: now declared a stable release.
2021-11-23 00:04:09 -08:00
Landon Curt Noll
e11d159c81 Release v2.14.0.7
The following are the changes in this release:

    Fizzbin is a better word. :-)

    The help and man builtin commands now return an error when a
    help file cannot be opened, such as when there is no help file.

    Added palindrome.cal resource file.  For example, to find the
    largest (highly probable) prime palindrome under 280 decimal
    digits (text tweet limit):

	prevprimepal(1e280)
2021-11-07 20:36:07 -08:00
Landon Curt Noll
dfd66be871 Adjusted calc in prep for 2.14.0.7 release 2021-11-07 20:30:23 -08:00
Landon Curt Noll
27f977b545 Remove unnecessary leading line whitespace before a tab 2021-11-07 20:14:28 -08:00
Landon Curt Noll
2ca6e789ca Add ignore win32 to .gitignore 2021-11-07 20:11:21 -08:00
Landon Curt Noll
ff8f921ebc Fix CHANGES note for palindrome.cal 2021-11-07 18:39:43 -08:00
Landon Curt Noll
005b78227a Minor comment changes to palindrome.cal 2021-11-07 18:36:06 -08:00
Landon Curt Noll
b7a42a9d3d Optimize palindrome.cal
In cal/palindrome.cal:

Improved the performace of nextpal() and nextprimepal()
by adding and using palnextpal().

Improved the performace of prevpal() and prevprimepal()
by adding and using palprevpal().

Test showed that runs that took 0.0530 cpu seconds can
now be done in as little as 0.0327 cpu seconds.
2021-11-07 14:15:19 -08:00
Landon Curt Noll
3d1e938cb6 Remove user_debug references in palindrome.cal 2021-11-07 13:34:58 -08:00
Landon Curt Noll
8b98a7c1f6 Add cal/palindrome.cal resource file 2021-11-06 14:48:45 -07:00
Landon Curt Noll
dbf5acf5e8 Improved help error messages
The help and man commands now issue an error message when
the help file cannot be opened: say because there is a
help command typo and there is no such help file.
2021-11-06 12:47:19 -07:00
Landon Curt Noll
5fe5ab1c4b Minor help improvement
Fizzbin is better than gleet.
2021-11-06 12:44:16 -07:00
Landon Curt Noll
e0cd9bb3db Release v2.14.0.6
The following are the changes in this release:

    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
2021-10-22 03:36:40 -07:00
Landon Curt Noll
f0f6171354 Release v2.14.0.5
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
2021-10-22 03:20:58 -07:00
Landon Curt Noll
94861cc6d2 Improved an internal allocation
Improved the way that the internal array,
consttable, is allocated.
2021-10-22 03:09:08 -07:00
Landon Curt Noll
286233e28f Fixed internal code bugs
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
2021-10-22 03:05:12 -07:00
Landon Curt Noll
99ac7836aa Create SECURITY.md 2021-10-22 01:46:12 -07:00
Landon Curt Noll
6c0c8e0ef6 Fixed issues noted by default GitHub code scan 2021-10-22 01:39:07 -07:00
Landon Curt Noll
8aa5f140bf Release v2.12.0.4 2021-10-22 01:26:25 -07:00
Landon Curt Noll
2fcb9a5995 Create codeql-analysis.yml 2021-10-22 01:25:16 -07:00
Landon Curt Noll
8b018b697d Updated CHANGES as per GitHub pull request #35 2021-10-21 12:21:10 -07:00
Landon Curt Noll
0e269ecd67 Merge pull request #35 from marcodegio/patch-1
Update README.WINDOWS
2021-10-21 12:15:56 -07:00
Landon Curt Noll
a640bc4656 Fixed typo in cal/statistics.cal
Thanks to a report by <GitHub user dennisaldea>.
2021-10-21 12:12:31 -07:00
Marco Degiovanni
62a95499ef Update README.WINDOWS
i changed the first line from Windoz to Windows
2021-10-21 20:05:11 +02:00
Landon Curt Noll
9e92d4a35a Change initnumbs[] to be NULL terminated 2021-09-28 22:32:06 -07:00
Landon Curt Noll
459c07b121 Release v2.14.0.3
The following are the changes in this release:

    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
2021-09-27 02:49:06 -07:00
Landon Curt Noll
ada15fdabc Added more builtin inverse conversion functions
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
2021-09-27 02:14:18 -07:00
Landon Curt Noll
d5de36841a Improve error codes for some invalid rounding args 2021-09-26 23:50:45 -07:00
Landon Curt Noll
cf419fb329 Added several conversion funcions, plus minor updates
Added several conversion functions:

    Added builtin functions to convert between degrees and
    degrees, minutes and seconds under the config("mod")
    round rules:

	d2dms(degs, d, m, s [,rnd]) - given degs, compute d, m, s
	d2dm(degs, d, m [,rnd]) - given degs, compute d, m

	See help/d2dms and help/d2dm.

    Example:

	; print d2dms(360.321,deg=,min=,sec=), deg, min, sec;
	0.321 0 19 15.6

	; print d2dm(360.321,deg=,min=), deg, min;
	0.321 0 19.26

    Added builtin functions to convert between gradians and
    gradians, minutes and seconds under the config("mod")
    round rules:

	g2gms(grads, g, m, s [,rnd]) - given grads, compute g, m, s
	g2gm(grads, g, m [,rnd]) - given grads, compute g, m

	See help/g2gms and help/g2gm.

    Example:

	; print g2gms(400.321,grad=,min=,sec=), grad, min, sec;
	0.321 0 19 15.6

	; print g2gm(400.321,grad=,min=), grad, min;
	0.321 0 19.26

    Added builtin functions to convert between hours and
    hours, minutes and seconds under the config("mod")
    round rules:

	h2hms(hours, h, m, s [,rnd]) - given hours, compute h, m, s
	h2hm(hours, h, m [,rnd]) - given hours, compute h, m

	See help/h2hms and help/h2hm.

    Example:

	; print h2hms(24.321,hour=,min=,sec=), hour, min, sec;
	0.321 0 19 15.6

	; print h2hm(24.321,hour=,min=), hour, min;
	0.321 0 19.26

In addtion:

    Renumbered regression tests 3408 thru 3437, to 9102 thru 9131.

    Updated Added hms.cal resource file to use h2hms() builtin.
    Updated Added dms.cal resource file to use d2dms() builtin.

    Fix minor typo in help/mod SYNOPSIS.
    Fix minor typo in help/quo SYNOPSIS.

    Added a few more examples to help/strcmp.
2021-09-26 04:38:09 -07:00
73 changed files with 3730 additions and 332 deletions

71
.github/workflows/codeql-analysis.yml vendored Normal file
View 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

1
.gitignore vendored
View File

@@ -94,6 +94,7 @@ sample_rand
tags
terminal.h
ver_calc
win32/
# other commonly excluded patterns
#

247
CHANGES
View File

@@ -1,4 +1,43 @@
The following are the changes from calc version 2.14.0.0 to date:
The following are the changes from calc version 2.14.0.9 to date:
Due to issues with clang and Apple Silicon, ARCH_CFLAGS is now,
by default, empty:
ARCH_CFLAGS=
If you want to use, say, -march=native, then either change
the Makefile or make with:
make all ARCH_CFLAGS='-march=native'
Added arch and hardware as GNU Makefile computed values.
As with ${target}, ${arch} and ${hardware} is computed by uname:
target: uname -a
arch: uname -p
hardware: uname -m
Fixed compiling calc on Apple Silicon with homebrew. On Apple
Silicon, HomeBrew installs on into a different location. The
Makefile checks if ${hardware} is arm64 and adjusts the location
of libraries such as readline and history accordingly.
The following are the changes from calc version 2.14.0.7 to 2.14.0.8:
Fizzbin is a better word. :-)
The help and man builtin commands now return an error when a
help file cannot be opened, such as when there is no help file.
Added palindrome.cal resource file. For example, to find the
largest (highly probable) prime palindrome under 280 decimal
digits (text tweet limit):
prevprimepal(1e280)
The following are the changes from calc version 2.14.0.0 to 2.14.0.6:
The :-separated default CALCRC value has been reversed.
The default CALCRC was:
@@ -78,10 +117,138 @@ The following are the changes from calc version 2.14.0.0 to date:
More changes are likely, so we might see another v2.14.0.x release
before things are declared "recommended stable".
Not that we wan to discourage people from trying v2.14.0, you should
Not that we want to discourage people from trying v2.14.0, you should
try it. We just want things to become stable and well field tested
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:
@@ -700,7 +867,7 @@ The following are the changes from calc version 2.12.5.4 to 2.12.5.6:
Rewrote gen_v1() in the lucas.cal resource file using the method
based on a paper:
"A note on primality tests for N = h*2^n-1", by Oystein J. Rodseth,
"A note on primality tests for N = h*2^n-1", by Oystein J. Rodseth,
Department of Mathematics, University of Bergen, BIT Numerical
Mathematics. 34 (3): pp 451-454.
@@ -759,13 +926,13 @@ The following are the changes from calc version 2.12.5.3 to 2.12.5.3:
macOS (Darwin) users who installed calc version 2.12.5.2
should, after installing version 2.12.5.3:
rm -rf /opt/calc
rm -rf /opt/calc
The following are the changes from calc version 2.12.5.1 to 2.12.5.2:
NOTE: calc version 2.12.5.2, for macOS (Darwin) users,
installed under /opt/calc. We neglected to mention this
installed under /opt/calc. We neglected to mention this
AND /usr/local would have been a better choice. Sorry!
Fixed in calc version 2.12.5.3.
@@ -838,7 +1005,7 @@ The following are the changes from calc version 2.12.4.14 to 2.12.5.0:
For Apple OS X / Darwin target:
MACOSX_DEPLOYMENT_TARGET is no longer defined
MACOSX_DEPLOYMENT_TARGET is no longer defined
using clang compiler
By default, -install-name is used when forming shared libs.
@@ -882,9 +1049,9 @@ The following are the changes from calc version 2.12.4.14 to 2.12.5.0:
for mul2, sq2, and pow2. However, it has been shown that this
code is not correct. Suggestions for a replacement are welcome!
calc -u 'read alg_config; config("user_debug", 2),; best_mul2();'
calc -u 'read alg_config; config("user_debug", 2),; best_sq2();'
calc -u 'read alg_config; config("user_debug", 2),; best_pow2();'
calc -u 'read alg_config; config("user_debug", 2),; best_mul2();'
calc -u 'read alg_config; config("user_debug", 2),; best_sq2();'
calc -u 'read alg_config; config("user_debug", 2),; best_pow2();'
Fixed a number of pedantic compiler warnings.
@@ -1051,7 +1218,7 @@ The following are the changes from calc version 2.12.4.6 to version 2.12.4.10:
With the exception of 3 source files, we became "picky" about
line lengths and other issues reported by the picky tool:
cal/test8900.cal
cal/test8900.cal
cal/set8700.line
help/errorcodes.sed
@@ -1107,7 +1274,7 @@ The following are the changes from calc version 2.12.4.0 to 2.12.4.2:
Added prep makefile rule to make is easier to compile calc without
an optimizer. By doing:
make clobber prep
make clobber prep
one may build a calc binary that is easier to debug.
@@ -1264,7 +1431,7 @@ The following are the changes from calc version 2.12.1.1 to 2.12.2.2:
what was calc-something.tar.gz is now calc-something.tar.bz2.
To "uncompress" use:
bunzip2 calc-something.tar.bz2
bunzip2 calc-something.tar.bz2
On some systems, one may untar directly by:
@@ -1329,7 +1496,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
Renamed the following variables related to calc error processing:
int calc_jmp ==> int calc_use_matherr_jmpbuf
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
int post_init ==> int calc_use_scanerr_jmpbuf
jmp_buf jmpbuf ==> jmpbuf calc_scanerr_jmpbuf
@@ -1344,7 +1511,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
Parse/scan errors will not be printed if calc_print_scanerr_msg
is zero. By default:
int calc_print_scanerr_msg = 1;
int calc_print_scanerr_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
@@ -1352,7 +1519,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
Parse/scan warnings will not be printed if calc_print_scanwarn_msg
is zero. By default:
int calc_print_scanwarn_msg = 1;
int calc_print_scanwarn_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
@@ -1388,13 +1555,13 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
Replaced the concept of compiler sets in the Makefile with
host target section in the Makefile. Initial host targets are:
Linux
Linux
Darwin
FreeBSD
(default) <<== Target does not match any previous target name
Simple
NOTE: If your target is not supported below and the default target
NOTE: If your target is not supported below and the default target
is not suitable for your needs, please send to the:
calc-contrib at asthe dot com
@@ -1542,7 +1709,7 @@ The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
comments. Improved calc comment documentation in "help unexpected"
to help other avoid similar mistakes. Calc comments are of the form:
/* c style comments */
/* c style comments */
/*
* multi-line
* comments
@@ -1556,7 +1723,7 @@ The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
Documented these help commands in "help help":
help ->
help ->
help *
help .
help %
@@ -1737,7 +1904,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
Added the builtin function fpathopen() to open a file while
searching along a path:
; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
; print fd2
"/var/tmp/date"
@@ -1787,12 +1954,12 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
level. When comparing with older source, one may use the -b argument
of the diff command to ignore changes in amount of white space:
diff -b -r -u calc-2.11.11 calc-2.12.0
diff -b -r -u calc-2.11.11 calc-2.12.0
The read, write, and help commands use the value of global string
variable if the symbol name starts with a $. For example:
global x = "lucas.cal";
global x = "lucas.cal";
read $x; /* same as read lucas.cal or read "lucas.cal" */
Added dotest.cal resource. Based on a design by Ernest Bowen
@@ -1902,7 +2069,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
Changed the default values for the following config() parameters:
config("mul2") == 1780
config("mul2") == 1780
config("sq2") == 3388
config("pow2") == 176
@@ -1997,10 +2164,10 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
value is TRUE by default. Examples of variable name collisions
include when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
Fix of a bug which causes some static variables not to be correctly
unscoped when their identifiers are used in a global declaration.
@@ -2020,7 +2187,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
Changed the definition of the function ssq() to enable list arguments
to be processed in the same way as in sum(). For example:
ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
returns the value of 1^2 + 2^2 + ... + 8^2 == 204.
@@ -2028,7 +2195,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
various ways of evaluating sums, sums of squares, etc, for large
lists and matrices. For example:
read sumtimes
read sumtimes
doalltimes(1e6)
Calc now ignores carriage returns (\r), vertical tabs (\v), and
@@ -2067,7 +2234,7 @@ The following are the changes from calc version 2.11.10.1 to 2.11.11:
Fixed a bug reported by the sourceforge user: cedars where:
ln(exp(6)) == 3 /* WRONG!!! */
ln(exp(6)) == 3 /* WRONG!!! */
incorrectly returned 1. This bug was fixed by Ernest Bowen
<ebowen at une dot edu dot au>. The regression test
@@ -2172,7 +2339,7 @@ The following are the changes from calc version 2.11.10 to 2.11.10:
Fixed -d so that:
calc -d 2/3
calc -d 2/3
will print 0.66666666666666666667 without the leading tilde as
advertised in the man page.
@@ -2192,7 +2359,7 @@ The following are the changes from calc version 2.11.10 to 2.11.10:
Added custom function:
custom("pmodm127", q)
custom("pmodm127", q)
to compute 2^(2^127-1) mod q. While currently slower than just
doing pmod(2,2^127-1,q), it is added to give an example of a
@@ -2283,7 +2450,7 @@ The following are the changes from calc version 2.11.8.0 to 2.11.8.1:
configuration (calc -n or config("all", "newstd")) is now the default
calc configuration. The flag:
calc -O
calc -O
was added to get the old classic calc configuration. The flag command
line flag, -n, now does nothing. Use of -n is deprecated and may go
@@ -2460,16 +2627,16 @@ The following are the changes from calc version 2.11.5.5 to 2.11.5.9:
Now using version numbers of one of these forms:
x.y.z.w
x.y.z
x.y
x.y.z.w
x.y.z
x.y
Changed the READLINE_LIB Makefile variable to not link with -lreadline
by default. If you do have readline, we recommend that you use it.
If you can install the GNU readline:
http://freshmeat.net/projects/gnureadline/
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
we recommend it. But if not, you should set the USE_READLINE,
READLINE_LIB, and READLINE_INCLUDE Makefile variables to empty.
@@ -2541,7 +2708,7 @@ The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
Added subject requirements for the calc-tester-request and
calc-bugs-mail Email aliases. See:
http://www.isthe.com/chongo/tech/comp/calc/email.html
http://www.isthe.com/chongo/tech/comp/calc/email.html
for details.
@@ -2708,7 +2875,7 @@ The following are the changes from calc version 2.11.5t2 to 2.11.5t2.1:
Applied a bug fix from Ernest Bowen <ernie at turing dot une dot
edu dot au> dealing with one-line "static" declaration like:
static a = 1, b;
static a = 1, b;
Added regression test 8310 to test for the static bug fix.
@@ -2821,7 +2988,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
Configuration values that used to return "true" or "false" now return
1 (a true value) or 0 (a false value). Thus one can do:
if (config("tab")) { ... } else { ... }
if (config("tab")) { ... } else { ... }
The configuration values that now return 1 or 0 are:

View File

@@ -46,6 +46,12 @@
ifeq ($(target),)
target=$(shell uname -s 2>/dev/null)
endif
ifeq ($(arch),)
arch=$(shell uname -p 2>/dev/null)
endif
ifeq ($(hardware),)
hardware=$(shell uname -m 2>/dev/null)
endif
# The shell used by this Makefile
#
@@ -135,15 +141,31 @@ USE_READLINE= -DUSE_READLINE
#READLINE_LIB= -L/usr/gnu/lib -lreadline -lhistory -lncurses
#READLINE_LIB= -L${PREFIX}/lib -lreadline -lhistory -lncurses
ifeq ($(target),Darwin)
# homebrew installs readline & history libs in ${PREFIX}/opt/readline/lib
ifeq ($(hardware),arm64)
# Darwin arm64 homebrew installs readline & history
# libs in /opt/homebrew/opt/readline/lib
READLINE_LIB= -L/opt/homebrew/opt/readline/lib -lreadline -lhistory -lncurses
else
# Assume Darwin non-arm64 is x86_64
# Darwin x86_64 homebrew installs readline & history
# libs in ${PREFIX}/opt/readline/lib
READLINE_LIB= -L${PREFIX}/opt/readline/lib -lreadline -lhistory -lncurses
endif
else
READLINE_LIB= -lreadline -lhistory -lncurses
endif
#
ifeq ($(target),Darwin)
# homebrew installs readline & history *.h under ${PREFIX}/opt/readline/include
ifeq ($(hardware),arm64)
# Darwin arm64 homebrew installs readline & history *.h
# under /opt/homebrew/opt/readline/include
READLINE_INCLUDE= -I${PREFIX}/opt/homebrew/opt/readline/include
else
# Assume Darwin non-arm64 is x86_64
# Darwin x86_64 homebrew installs readline & history *.h
# under ${PREFIX}/opt/readline/include
READLINE_INCLUDE= -I${PREFIX}/opt/readline/include
endif
else
READLINE_INCLUDE=
endif

View File

@@ -79,6 +79,12 @@ SHELL= /bin/sh
ifeq ($(target),)
target=$(shell uname -s 2>/dev/null)
endif
ifeq ($(arch),)
arch=$(shell uname -p 2>/dev/null)
endif
ifeq ($(hardware),)
hardware=$(shell uname -m 2>/dev/null)
endif
#endif /* end of skip for non-Gnu makefiles */
##############################################################################
@@ -1205,7 +1211,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.0.2
VERSION= 2.14.0.9
# Names of shared libraries with versions
#
@@ -1280,8 +1286,8 @@ EXTRA_LDFLAGS=
# The ARCH_CFLAGS are ${CC} when compiling C files. They follow
# CCMISC and precede EXTRA_CFLAGS.
#
ARCH_CFLAGS= -march=native
#ARCH_CFLAGS=
ARCH_CFLAGS=
#ARCH_CFLAGS= -march=native
# COMMON_CFLAGS are the common ${CC} flags used for all programs, both
# intermediate and final calc and calc related programs

View File

@@ -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
View 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.

View File

@@ -275,17 +275,17 @@ CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
constants.cal deg.cal dms.cal dotest.cal ellip.cal factorial.cal \
factorial2.cal gvec.cal hello.cal hms.cal infinities.cal intfile.cal \
intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal pell.cal \
pi.cal pix.cal pollard.cal poly.cal prompt.cal psqrt.cal qtime.cal \
quat.cal randbitrun.cal randmprime.cal randombitrun.cal randomrun.cal \
randrun.cal regress.cal repeat.cal screen.cal seedrandom.cal \
set8700.cal set8700.line smallfactors.cal solve.cal \
specialfunctions.cal statistics.cal strings.cal sumsq.cal sumtimes.cal \
surd.cal test1700.cal test2300.cal test2600.cal test2700.cal \
test3100.cal test3300.cal test3400.cal test3500.cal test4000.cal \
test4100.cal test4600.cal test5100.cal test5200.cal test8400.cal \
test8500.cal test8600.cal test8900.cal toomcook.cal unitfrac.cal \
varargs.cal xx_print.cal zeta2.cal
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal \
palindrome.cal pell.cal pi.cal pix.cal pollard.cal poly.cal prompt.cal \
psqrt.cal qtime.cal quat.cal randbitrun.cal randmprime.cal \
randombitrun.cal randomrun.cal randrun.cal regress.cal repeat.cal \
screen.cal seedrandom.cal set8700.cal set8700.line smallfactors.cal \
solve.cal specialfunctions.cal statistics.cal strings.cal sumsq.cal \
sumtimes.cal surd.cal test1700.cal test2300.cal test2600.cal \
test2700.cal test3100.cal test3300.cal test3400.cal test3500.cal \
test4000.cal test4100.cal test4600.cal test5100.cal test5200.cal \
test8400.cal test8500.cal test8600.cal test8900.cal toomcook.cal \
unitfrac.cal varargs.cal xx_print.cal zeta2.cal
# These calc files are now obsolete and are removed by the install rule.
#

View File

@@ -186,7 +186,7 @@ bernoulli.cal
Calculate the nth Bernoulli number.
NOTE: There is now a bernoulli() builtin function. This file is
left here for backward compatibility and now simply returns
left here for backward compatibility and now simply returns
the builtin function.
@@ -767,7 +767,7 @@ lucas.cal
prove that h*2^n-1 is prime or not prime.
NOTE: Some call this term u(0). The function gen_u0(h, n, v1)
simply calls gen_u2(h, n, v1) for such people. :-)
simply calls gen_u2(h, n, v1) for such people. :-)
gen_v1(h, v)
@@ -879,6 +879,38 @@ natnumset.cal
user-specified bound.
palindrome.cal
digitof(val,place)
copalplace(d,place)
upperhalf(val)
mkpal(val)
mkpalmiddigit(val,digit)
ispal(val)
nextpal(val)
prevpal(val)
nextprimepal(val)
prevprimepal(val)
Functions to form and manipulate palendromes in base 10.
Important functions are:
Find the next / previous palindrome:
nextpal(val)
prevpal(val)
Test if a value is a palindrome:
ispal(val)
Find the next / previous palindrome that is a (highly probable) prime:
nextprimepal(val)
prevprimepal(val)
pell.cal
pellx(D)
@@ -1435,7 +1467,7 @@ sumtimes.cal
the list or matrix to use. The doalltimes() function will run
all of the sumtimes tests. For example:
doalltimes(1e6);
doalltimes(1e6);
surd.cal

View File

@@ -474,7 +474,7 @@ define best_mul2()
*/
while (low+1 < high) {
/* try the mid-point */
/* try the mid-point */
mid = int((low+high)/2);
if (config("user_debug") > 0) {
printf("testing multiply alg1/alg2 ratio for len = %d\n", mid);
@@ -956,7 +956,7 @@ define best_sq2()
*/
while (low+1 < high) {
/* try the mid-point */
/* try the mid-point */
mid = int((low+high)/2);
if (config("user_debug") > 0) {
printf("testing square alg1/alg2 ratio for len = %d\n", mid);
@@ -1455,7 +1455,7 @@ define best_pow2()
*/
while (low+1 < high) {
/* try the mid-point */
/* try the mid-point */
mid = int((low+high)/2);
if (config("user_debug") > 0) {
printf("testing pow2 alg1/alg2 ratio for len = %d\n", mid);

View File

@@ -40,7 +40,7 @@ define Z(x, eps_term)
/* obtain the error term */
if (isnull(eps_term)) {
eps = epsilon();
eps = epsilon();
} else {
eps = eps_term;
}
@@ -81,7 +81,7 @@ define P(x, eps_term)
/* obtain the error term */
if (isnull(eps_term)) {
eps = epsilon();
eps = epsilon();
} else {
eps = eps_term;
}

View File

@@ -188,7 +188,7 @@ define dms_abs(a)
/* firewall - just absolute value non dms objects */
if (! istype(a, ans)) {
return abs(a);
return abs(a);
}
/* compute degrees */
@@ -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;

View File

@@ -157,7 +157,7 @@ define dotest(dotest_file, dotest_code = 0, dotest_maxcond = -1)
* test the close of the line file
*/
printf("%d-: detected %d error condition(s), many of which may be OK\n",
dotest_code, dotest_old_errcount-dotest_errcnt);
dotest_code, dotest_old_errcount-dotest_errcnt);
printf("%d-: closing line file: %d\n", dotest_code, dotest_file);
fclose(dotest_f_file);

View File

@@ -56,7 +56,7 @@ define __CZ__factor_factorial(n,start){
if(start){
if(!isint(start) && start < 0 && start > n)
return newerror("__CZ__factor_factorial(n,start): value of "
"parameter 'start' out of range");
"parameter 'start' out of range");
if(start == n && isprime(n)){
prime_list = mat[1 , 2];
prime_list[0,0] = n;
@@ -64,7 +64,7 @@ define __CZ__factor_factorial(n,start){
}
else if(!isprime(start) && nextprime(start) >n)
return newerror("__CZ__factor_factorial(n,start): value of parameter "
"'start' out of range");
"'start' out of range");
else{
if(!isprime(start)) prime = nextprime(start);
else prime = start;
@@ -225,11 +225,11 @@ define __CZ__multiply_factored_factorial(matrix,stop){
if(!ismat(matrix))
return newerror("__CZ__multiply_factored_factorial(matrix): "
"argument matrix not a matrix ");
"argument matrix not a matrix ");
if(!matrix[0,0])
return
newerror("__CZ__multiply_factored_factorial(matrix): "
"matrix[0,0] is null/0");
"matrix[0,0] is null/0");
if(!isnull(stop))
pix = stop;
@@ -376,7 +376,7 @@ define bigcatalan(n){
/*
df(-111) = -1/3472059605858239446587523014902616804783337112829102414124928
7753332469144201839599609375
7753332469144201839599609375
df(-3+1i) = 0.12532538977287649201-0.0502372106177184607i
df(2n + 1) = (2*n)!/(n!*2^n)
@@ -427,7 +427,7 @@ define doublefactorial(n){
*/
eps=epsilon(epsilon()*1e-2);
ret = 2^(n/2-1/4 * cos(pi()* n)+1/4) * pi()^(1/4 *
cos(pi()* n)-1/4)* gamma(n/2+1);
cos(pi()* n)-1/4)* gamma(n/2+1);
epsilon(eps);
return ret;
}

View File

@@ -188,7 +188,7 @@ define hms_abs(a)
/* firewall - just absolute value non hms objects */
if (! istype(a, ans)) {
return abs(a);
return abs(a);
}
/* compute hours */
@@ -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;

View File

@@ -156,7 +156,7 @@ define be2file(v, filename)
*/
octlen = int((highbit(v)+8) / 8);
for (i=octlen-1; i >= 0; --i) {
fputc(fd, char(v >> (i*8)));
fputc(fd, char(v >> (i*8)));
}
/*

View File

@@ -731,7 +731,7 @@ rodseth_xhn(x, h, n)
return 0;
}
/*
/*
* Check for jacobi(x-2, h*2^n-1) == 1 (Ref4, condition 1) part 1
*/
testval = h*2^n-1;
@@ -739,7 +739,7 @@ rodseth_xhn(x, h, n)
return 0;
}
/*
/*
* Check for jacobi(x+2, h*2^n-1) == -1 (Ref4, condition 1) part 2
*/
if (jacobi(x+2, testval) != -1) {

641
cal/palindrome.cal Normal file
View File

@@ -0,0 +1,641 @@
/*
* palindrome - palindrome utilities
*
* 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/11/06 14:35:37
* File existed as early as: 2021
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* digitof - return the a digit of a value
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val value to find a digit of
* place digit place
*
* returns:
* value (>= 0 and < 10) that is the place-th digit of val
* or 0 if place is not a digit of val
*/
define digitof(val, place)
{
local d; /* length of val in digits */
/* determine length */
d = digits(val);
/* firewall - return 0 if digit place doesn't exist */
if (place < 1 || place > d) {
return 0;
}
/* return the place-th digit of val as a single digit */
return (val // (10^(place-1))) % 10;
}
/*
* copalplace - determine the other place in a palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* d digits of a value
* place digit place
*
* returns:
* given palindrome val, the other digit paired with place
* or 0 if place is not a digit of val
*/
define copalplace(d, place)
{
/* firewall - return 0 if digit place doesn't exist */
if (d < 1 || place < 1 || place > d) {
return 0;
}
/* return digit coplace */
return d+1 - place;
}
/*
* upperhalf - return the upper half of a palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* NOTE: When the value has an odd number of digits, the upper half
* includes the middle digit.
*
* given:
* val a value
*
* returns:
* the upper half digits of a value
*/
define upperhalf(val)
{
local d; /* length of val in digits */
local halfd; /* length of upper hand of val */
/* determine length */
d = digits(val);
halfd = d // 2;
/* return upper half */
return (val // 10^halfd);
}
/*
* mkpal - make a value into a palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* val as a palindrome with lower half being reverse digits of val
*/
define mkpal(val)
{
local d; /* length of val in digits */
local i; /* counter */
local ret; /* palindrome being formed */
/* determine length */
d = digits(val);
/* insert digits in reverse order at the bottom */
ret = val;
for (i=0; i < d; ++i) {
ret = ret*10 + digit(val, i);
}
return ret;
}
/*
* mkpalmiddigit - make a value into a palindrome with a middle digit
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
* digit the digit to put into the middle of the palindrome
*
* returns:
* val as a palindrome with lower half being reverse digits of val
* and digit as a middle digit
*/
define mkpalmiddigit(val, digit)
{
local d; /* length of val in digits */
local i; /* counter */
local ret; /* palindrome being formed */
/* determine length */
d = digits(val);
/* insert digits in reverse order at the bottom */
ret = val*10 + digit;
for (i=0; i < d; ++i) {
ret = ret*10 + digit(val, i);
}
return ret;
}
/*
* ispal - determine if a value is a palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* 1 ==> val is a palindrome
* 0 ==> val is NOT a palindrome
*/
define ispal(val)
{
local half; /* upper half of digits of val */
local digit; /* middle digit */
/* case: val has an even number of digits */
if (iseven(digits(val))) {
/* test palindrome-ness */
return (val == mkpal(upperhalf(val)));
/* case: val can an odd number of digits */
} else {
/* test palindrome-ness */
half = upperhalf(val);
digit = half % 10;
half //= 10;
return (val == mkpalmiddigit(half, digit));
}
}
/*
* palnextpal - return next palindrome from a known palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* pal a palindrome
*
* returns:
* next palindrome > pal
*/
define palnextpal(pal)
{
local paldigits; /* digits in pal */
local half; /* upper half of newval */
local newhalf; /* half+1 */
local newpal; /* new palindrome */
/* case: negative palindrome */
if (pal < 0) {
return -(palprevpal(-pal));
}
/*
* start with upper half
*/
half = upperhalf(pal);
/*
* prep to find a larger palindrome
*/
newhalf = half+1;
/*
* form palindrome from new upper half
*
* We need to watch for the corner case where changing the
* half changes the number of digits as this will impact
* or even/odd number of digits processing.
*/
paldigits = digits(pal);
if (digits(newhalf) == digits(half)) {
/* no change in half digits: process as normal */
if (iseven(paldigits)) {
newpal = mkpal(newhalf);
} else {
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
}
} else {
/* change in half digits: process as opposite */
if (iseven(paldigits)) {
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
} else {
newpal = mkpal(newhalf);
}
}
/*
* return the new palindrome
*/
return newpal;
}
/*
* nextpal - return next palindrome from a value
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* next palindrome > val
*/
define nextpal(val)
{
local newval; /* val+1 */
local newvaldigits; /* digits in newval */
local half; /* upper half of newval */
local pal; /* palindrome test value */
local newpal; /* new palindrome */
/* case: negative value */
if (val < 0) {
return -(prevpal(-val));
}
/*
* start looking from a larger value
*/
newval = val+1;
newvaldigits = digits(newval);
/* case: single digit palindrome */
if (newvaldigits < 2) {
return newval;
}
/*
* start with next upper half
*/
half = upperhalf(newval);
/*
* form palindrome from upper half
*
* We need to deal with even vs. odd digit counts
* when forming a palindrome from a half as the
* half may not or may include the middle digit.
*/
if (iseven(newvaldigits)) {
pal = mkpal(half);
} else {
pal = mkpalmiddigit(half // 10, half % 10);
}
/*
* case: we found a larger palindrome, we are done
*/
if (pal > val) {
return pal;
}
/*
* we need to find an even larger palindrome
*/
newpal = palnextpal(pal);
/*
* return the new palindrome
*/
return newpal;
}
/*
* palprevpal - return previous palindrome from a palindrome
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* pal a palindrome
*
* returns:
* previous palindrome < pal
*/
define palprevpal(pal)
{
local paldigits; /* digits in pal */
local half; /* upper half of newval */
local newhalf; /* half+1 */
local newpal; /* new palindrome */
/* case: negative value */
if (pal < 0) {
return -(palnextpal(-pal));
}
/* case: single digit palindrome */
if (pal < 10) {
newpal = pal-1;
return newpal;
}
/* case: 10 or 11 */
if (pal < 12) {
newpal = 9;
return newpal;
}
/*
* start with upper half
*/
half = upperhalf(pal);
/*
* prep to find a smaller palindrome
*/
newhalf = half-1;
/*
* form palindrome from new upper half
*
* We need to watch for the corner case where changing the
* half changes the number of digits as this will impact
* or even/odd number of digits processing.
*/
paldigits = digits(pal);
if (digits(newhalf) == digits(half)) {
/* no change in half digits: process as normal */
if (iseven(paldigits)) {
newpal = mkpal(newhalf);
} else {
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
}
} else {
/* change in half digits: process as opposite */
if (iseven(paldigits)) {
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
} else {
newpal = mkpal(newhalf);
}
}
/*
* return the new palindrome
*/
return newpal;
}
/*
* prevpal - return previous palindrome from a value
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* previous palindrome < val
*/
define prevpal(val)
{
local newval; /* val-1 */
local newvaldigits; /* digits in newval */
local half; /* upper half of newval */
local pal; /* palindrome test value */
local newpal; /* new palindrome */
/* case: negative value */
if (val < 0) {
return -(nextpal(-val));
}
/*
* start looking from a smaller value
*/
newval = val-1;
newvaldigits = digits(newval);
/* case: single digit palindrome */
if (newvaldigits < 2) {
return newval;
}
/*
* start with previous upper half
*/
half = upperhalf(newval);
/*
* form palindrome from upper half
*
* We need to deal with even vs. odd digit counts
* when forming a palindrome from a half as the
* half may not or may include the middle digit.
*/
if (iseven(newvaldigits)) {
pal = mkpal(half);
} else {
pal = mkpalmiddigit(half // 10, half % 10);
}
/*
* case: we found a smaller palindrome, we are done
*/
if (pal < val) {
return pal;
}
/*
* we need to find an even smaller palindrome
*/
newpal = palprevpal(pal);
/*
* return the new palindrome
*/
return newpal;
}
/*
* nextprimepal - return next palindrome that is a (highly probable) prime
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* next palindrome (highly probable) prime > val
*/
define nextprimepal(val)
{
local pal; /* palindrome test value */
local dpal; /* digits in pal */
/*
* pre-start under the next palindrome
*/
pal = nextpal(val-1);
/*
* loop until we find a (highly probable) prime or 0
*/
do {
/* case: negative values and tiny values */
if (pal < 2) {
return 2;
}
/*
* compute the next palindrome
*/
pal = palnextpal(pal);
dpal = digits(pal);
/* case: 11 is the only prime palindrome with even digit count */
if (pal == 11) {
return 11;
}
/* case: even number of digits and not 11 */
if (iseven(dpal)) {
/*
* Except for 11 (which is handled above already), there are
* no prime palindrome with even digits. So we need to
* increase the digit count and work with that larger palindrome.
*/
pal = nextpal(10^dpal);
}
/* case: palindrome is even or ends in 5 */
if (iseven(pal % 10) || (pal%10 == 10/2)) {
/*
* we need to increase the bottom and top digits
* so that we have a chance to be prime
*/
pal += (1 + 10^(dpal-1));
}
if (config("resource_debug") & 0x8) {
print "DEBUG: nextprimepal:", pal;
}
} while (ptest(pal) == 0 && pal > 0);
/* return palindrome that his (highly probable) prime or 0 */
return pal;
}
/*
* prevprimepal - return prev palindrome that is a (highly probable) prime
*
* NOTE: We assume base 10 digits and place 1 is the units digit.
*
* given:
* val a value
*
* returns:
* prev palindrome (highly probable) prime < val or 0
*/
define prevprimepal(val)
{
local pal; /* palindrome test value */
local dpal; /* digits in pal */
/*
* pre-start over the previous palindrome
*/
pal = prevpal(val+1);
/*
* loop until we find a (highly probable) prime or 0
*/
do {
/*
* case: single digit values are always palindromes
*/
if (val < 10) {
/*
* The prevcand() call will return 0 if there is no previous prime
* such as the case when val < 2.
*/
return prevcand(pal);
}
/*
* compute the previous palindrome
*/
pal = palprevpal(pal);
dpal = digits(pal);
/* case: 11 is the only prime palindrome with even digit count */
if (pal == 11) {
return 11;
}
/* case: 2 digit palindrome and not 11 */
if (dpal == 2) {
return 7;
}
/* case: even number of digits */
if (iseven(dpal)) {
/*
* Except for 11 (which is handled above already), there are
* no prime palindrome with even digits. So we need to
* decrease the digit count and work with that smaller palindrome.
*/
pal = prevpal(10^(dpal-1));
}
/* case: palindrome is even or ends in 5 */
if (iseven(pal % 10) || (pal%10 == 10/2)) {
/*
* we need to decrease the bottom and top digits
* so that we have a chance to be prime
*/
pal -= (1 + 10^(dpal-1));
}
if (config("resource_debug") & 0x8) {
print "DEBUG: prevprimepal:", pal;
}
} while (ptest(pal) == 0 && pal > 0);
/* return palindrome that his (highly probable) prime or 0 */
return pal;
}

View File

@@ -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()
{
@@ -3404,74 +3406,6 @@ define test_trig()
tnum = test3400(1, 3401);
vrfy(tnum == 3407, '3407: tnum == 3407');
/* d2r & r2d */
vrfy(d2r(180) == pi(),
'3408: d2r(180) == pi()');
vrfy(d2r(180, 1e-100) == pi(1e-100),
'3409: d2r(180, 1e-100) == pi(1e-100)');
vrfy(r2d(pi()/2) == 90,
'3410: r2d(pi()/2) == 90');
vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923,
'3411: r2d(pi(1e-15)/2) == ' +
'14137166941154068500000/157079632679489661923');
vrfy(r2d(d2r(40)) == 40,
'3412: r2d(d2r(40)) == 40');
vrfy(r2d(d2r(40,1e-90),1e-90) == 40,
'3413: r2d(d2r(40,1e-90),1e-90) == 40');
vrfy(d2r(180i) == 1i*pi(),
'3414: d2r(1808) == 1i*pi()');
vrfy(d2r(180i+90) == 1i*pi() + pi()/2,
'3415: d2r(180i+90) == 1i*pi() + pi()/2');
vrfy(r2d(d2r(40+40i)) == 40+40i,
'3416: r2d(d2r(40+40i)) == 40+40i');
vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i,
'3417: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i');
/* g2r & r2g */
vrfy(g2r(200) == pi(),
'3418: g2r(200) == pi()');
vrfy(g2r(200, 1e-100) == pi(1e-100),
'3419: g2r(180, 1e-100) == pi(1e-100)');
vrfy(r2g(pi()/2) == 100,
'3420: r2g(pi()/2) == 100');
vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923,
'3421: r2g(pi(1e-15)/2) == ' +
'15707963267948965000000/157079632679489661923');
vrfy(r2g(g2r(40)) == 40,
'3422: r2g(g2r(40)) == 40');
vrfy(r2g(g2r(40,1e-90),1e-90) == 40,
'3423: r2g(g2r(40,1e-90),1e-90) == 40');
vrfy(g2r(200i) == 1i*pi(),
'3424: g2r(200i) == 1i*pi()');
vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(),
'3425: g2r(200i+150) == pi()*0.75 + 1i*pi()');
vrfy(r2g(g2r(40+40i)) == 40+40i,
'3426: r2g(g2r(40+40i)) == 40+40i');
vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i,
'3427: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i');
/* g2d & d2g */
vrfy(g2d(200) == 180,
'3428: g2d(200) == 180');
vrfy(g2d(200, 1e-100) == 180,
'3429: g2d(180, 1e-100) == 180');
vrfy(d2g(81) == 90,
'3430: d2g(81) == 90');
vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000,
'3431: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000');
vrfy(d2g(g2d(40)) == 40,
'3432: d2g(g2d(40)) == 40');
vrfy(d2g(g2d(40,1e-90),1e-90) == 40,
'3433: d2g(g2d(40,1e-90),1e-90) == 40');
vrfy(g2d(200i) == 180i,
'3434: g2d(200i) == 180i');
vrfy(g2d(200i+47) == 42.3 + 180i,
'3435: g2d(200i+47) == 42.3 + 180i');
vrfy(d2g(g2d(40+40i)) == 40+40i,
'3436: d2g(g2d(40+40i)) == 40+40i');
vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i,
'3437: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i');
print '3438: Ending test_trig';
}
print '051: parsed test_trig()';
@@ -8235,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()
{
@@ -8348,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
*

View File

@@ -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){

View File

@@ -336,7 +336,7 @@ define __CZ__produce_long_random_number(n)
ret = 1;
if(!isint(n) || n<1)
return newerror("__CZ__produce_long_random_number(n): "
"n is not an integer >=1");
"n is not an integer >=1");
for(k=0;k<n;k++){
ret += random();
ret = toomcook4square(ret);

View File

@@ -72,7 +72,7 @@ define hurwitzzeta(s,a){
limit=(precision*ln(10)-re((s-.5)*result)+(1.*realpart_a)*ln(2.*pi()))/2;
limit=max(2,ceil(max(limit,abs(s*1.)/2)));
limit_function=ceil(sqrt((limit+realpart_a/2-.25)^2+(imagpart_s*1.)^2/4)/
pi());
pi());
if (config("user_debug") > 0) {
print "limit_function = " limit_function;
print "limit = " limit;

View File

@@ -506,3 +506,39 @@ 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
View File

@@ -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;

View File

@@ -374,12 +374,12 @@ Step 5: Write your custom function
One is able to set bit 8 by way of the calc command line:
calc -D 128
calc -D 128
See the calc man page for details. One may also set that bit
while running calc by way of the config() builtin function:
config("calc_debug", 128);
config("calc_debug", 128);
See the help/config file for details on calc_debug.

View File

@@ -496,7 +496,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.0.2
VERSION= 2.14.0.9
# Names of shared libraries with versions
#

View File

@@ -496,7 +496,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.0.2
VERSION= 2.14.0.9
# Names of shared libraries with versions
#

View File

@@ -13,7 +13,7 @@ DESCRIPTION
This custom function will return the value:
q mod 2^(2^127-1)
q mod 2^(2^127-1)
This custom function serves as a demonstration of how to write
a custom function. It performs the equivalent of:

1066
func.c

File diff suppressed because it is too large Load Diff

View File

@@ -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

59
help.c
View File

@@ -29,6 +29,7 @@
#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/errno.h>
#include "calc.h"
#include "conf.h"
@@ -83,6 +84,9 @@ STATIC struct help_alias {
{"show", "command"},
{"stdlib", "resource"},
{"question", "questions"},
{"dm2d", "dms2d"},
{"gm2g", "gms2g"},
{"hm2d", "hms2d"},
{NULL, NULL}
};
@@ -259,6 +263,7 @@ givehelp(char *type)
}
snprintf(helppath, snprintf_len, "%s/%s", calc_helpdir, type);
helppath[snprintf_len] = '\0'; /* paranoia */
errno = 0;
stream = fopen(helppath, "r");
if (stream != NULL) {
@@ -273,30 +278,42 @@ givehelp(char *type)
* open the helpfile (looking in CUSTOMHELPDIR last)
*/
} else {
char *cust_helppath; /* path to the custom help file */
size_t cust_snprintf_len; /* malloced custom snprintf buf len */
char *cust_helppath; /* path to the custom help file */
size_t cust_snprintf_len; /* malloced custom snprintf buf len */
cust_snprintf_len = strlen(calc_customhelpdir)+1+strlen(type) + 1;
cust_helppath = (char *)malloc(cust_snprintf_len+1);
if (cust_helppath == NULL) {
fprintf(stderr, "malloc failure for givehelp #1\n");
return;
}
snprintf(cust_helppath, cust_snprintf_len,
"%s/%s", calc_customhelpdir, type);
cust_helppath[cust_snprintf_len] = '\0'; /* paranoia */
stream = fopen(cust_helppath, "r");
if (stream != NULL) {
cust_snprintf_len =
strlen(calc_customhelpdir)+1+strlen(type) + 1;
cust_helppath = (char *)malloc(cust_snprintf_len+1);
if (cust_helppath == NULL) {
fprintf(stderr, "malloc failure for givehelp #1\n");
return;
}
snprintf(cust_helppath, cust_snprintf_len,
"%s/%s", calc_customhelpdir, type);
cust_helppath[cust_snprintf_len] = '\0'; /* paranoia */
errno = 0;
stream = fopen(cust_helppath, "r");
if (stream != NULL) {
/*
* we have the help file open, now display it
*/
page_file(stream);
(void) fclose(stream);
}
free(cust_helppath);
cust_helppath = NULL;
/*
* we have the help file open, now display it
*/
page_file(stream);
(void) fclose(stream);
/* unable to open help file */
} else {
fprintf(stderr, "unable to open help file: %s - %s\n",
type, strerror(errno));
}
free(cust_helppath);
cust_helppath = NULL;
#else /* CUSTOM */
/* unable to open help file */
} else {
fprintf(stderr, "unable to open help file: %s - %s\n",
type, strerror(errno));
#endif /* CUSTOM */
}

View File

@@ -364,32 +364,33 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2g d2r \
delete den dereference det digit digits display dp epsilon errcount \
errmax errno error estr euler eval exp fact factor fclose fcnt feof \
ferror fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib \
files floor fopen forall fpathopen fprintf fputc fputs fputstr frac \
free freebernoulli freeeuler freeglobals freeredc freestatics frem \
freopen fscan fscanf fseek fsize ftell g2d g2r gcd gcdrem gd \
getenv hash head highbit hmean hnrmod hypot ilog ilog10 ilog2 im \
indices inputlevel insert int inverse iroot isalnum isalpha isassoc \
isatty isblk iscntrl isconfig isdefined isdigit iserror iseven isfile \
isgraph ishash isident isint islist islower ismat ismult isnull isnum \
isobj isobjtype isodd isprime isprint isptr ispunct isqrt isrand \
israndom isreal isrel issimple isspace issq isstr istype isupper \
isxdigit jacobi join lcm lcmfact lfactor ln log lowbit ltol makelist \
matdim matfill matmax matmin matsum mattrace mattrans max memsize meq \
min minv mmin mne mod modify name near newerror nextcand nextprime \
norm null num oldvalue ord param perm pfact pi pix places pmod polar \
poly pop popcnt pound power prevcand prevprime printf prompt protect \
ptest push putenv quo quomod r2d r2g rand randbit random randombit \
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
round rsearch runtime saveval scale scan scanf search sec sech seed \
segment select sgn sha1 sin sinh size sizeof sleep sort sqrt srand \
srandom ssq stoponerror str strcasecmp strcat strcmp strcpy strerror \
strlen strncasecmp strncmp strncpy strpos strprintf strscan strscanf \
strtolower strtoupper substr sum swap system systime tail tan tanh \
test time trunc usertime version xor
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
d2dms d2g d2r delete den dereference det digit digits display 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 \
isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
name near newerror nextcand nextprime norm null num oldvalue ord param \
perm pfact pi pix places pmod polar poly pop popcnt pound power \
prevcand prevprime printf prompt protect ptest push putenv quo quomod \
r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
rcsq re remove reverse rewind rm root round rsearch runtime saveval \
scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
sum swap system systime tail tan tanh test time trunc usertime version \
xor
# This list is of files that are clones of DETAIL_HELP files. They are
# built from DETAIL_HELP files.

View File

@@ -79,7 +79,7 @@ EXAMPLE
10 /* 012 */
; base2(16),
; 131072
131072 /* 0x20000 */
131072 /* 0x20000 */
; 2345
2345 /* 0x929 */
@@ -96,7 +96,7 @@ LINK LIBRARY
SEE ALSO
base, config, str
## Copyright (C) 2002 Landon Curt Noll
## Copyright (C) 2002,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

View File

@@ -866,10 +866,10 @@ DESCRIPTION
when a variable name collides with an exist name of a higher scope.
Examples of collisions are when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
The initial "redecl_warn" value is 1.
@@ -895,7 +895,7 @@ EXAMPLE
1
; config("version")
"2.12.0"
"2.12.0"
; config("all")
mode "real"

117
help/d2dm Normal file
View File

@@ -0,0 +1,117 @@
NAME
d2dm - convert degrees into degrees, and minutes
SYNOPSIS
d2dm(degs, d, m [,rnd])
TYPES
degs real
d null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(degs, 360, rnd)
DESCRIPTION
Convert degs degrees into d degrees, and m minutes.
The return value is a normalized number of degrees, and is equivalent
to the following:
return_value = mod(degs, 360, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 360) or a real value in the interval (-360, 0].
For the default round mode, the return value is in the interval [0, 360).
The d argument will be an integer number of degrees.
The value d will be set as if the following were used:
d = int(return_value);
For some rounding modes, d will be an integer in the interval [0, 360).
For other rounding modes, d will be an integer in the interval (-360, 0].
For the default round mode, d is in the interval [0, 360).
The m argument will be a real number of minutes.
The value m will be set as if the following were used:
tmp = return_value - d;
m = tmp * 60;
free(tmp);
For some rounding modes, m will be a real value in the interval [0, 60).
For other rounding modes, m will be a real value in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
d, and m values:
return_value == d + m/60;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global d, m;
; print d2dm(12.3456,d,m), d, m;
12.3456 12 20.736
; print d2dm(1234.5678,d,m), d, m;
154.5678 154 34.068
; print d2dm(-1234.5678,d,m), d, m;
205.4322 205 25.932
; print d2dm(654.321,deg=,min=), deg, min;
294.321 294 19.26
; print d2dm(-654.321,deg=,min=), deg, min;
65.679 65 40.74
; print d2dm(360.321,deg=,min=), deg, min;
0.321 0 19.26
/* certain non-default rounding modes can return negative values */
; print d2dm(654.321,deg=,min=,1), deg, min;
-65.679 -65 -40.74
; print d2dm(-654.321,deg=,min=,1), deg, min;
-294.321 -294 -19.26
; print d2dm(360.321,deg=,min=,1), deg, min;
-359.679 -359 -40.74
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
h2hm, h2hms, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

132
help/d2dms Normal file
View File

@@ -0,0 +1,132 @@
NAME
d2dms - convert degrees into degrees, minutes, and seconds
SYNOPSIS
d2dms(degs, d, m, s [,rnd])
TYPES
degs real
d null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(degs, 360, rnd)
DESCRIPTION
Convert degs degrees into d degrees, m minutes, and s seconds.
The return value is a normalized number of degrees, and is equivalent
to the following:
return_value = mod(degs, 360, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 360) or a real value in the interval (-360, 0].
For the default round mode, the return value is in the interval [0, 360).
The d argument will be an integer number of degrees.
The value d will be set as if the following were used:
d = int(return_value);
For some rounding modes, d will be an integer in the interval [0, 360).
For other rounding modes, d will be an integer in the interval (-360, 0].
For the default round mode, d is in the interval [0, 360).
The m argument will be an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - d;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
d, m, and s values:
return_value == d + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global d, m, s;
; print d2dms(12.3456,d,m,s), d, m, s;
12.3456 12 20 44.16
; print d2dms(1234.5678,d,m,s), d, m, s;
154.5678 154 34 4.08
; print d2dms(-1234.5678,d,m,s), d, m, s;
205.4322 205 25 55.92
; print d2dms(654.321,deg=,min=,sec=), deg, min, sec;
294.321, 294, 19, 15.6
; print d2dms(-654.321,deg=,min=,sec=), deg, min, sec;
65.679 65 40 44.4
; print d2dms(360.321,deg=,min=,sec=), deg, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print d2dms(654.321,deg=,min=,sec=,1), deg, min, sec;
-65.679 -65 -40 -44.4
; print d2dms(-654.321,deg=,min=,sec=,1), deg, min, sec;
-294.321 -294 -19 -15.6
; print d2dms(360.321,deg=,min=,sec=,1), deg, min, sec;
-359.679 -359 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
h2hm, h2hms, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -73,8 +73,8 @@ EXAMPLE
; for (n = 6; n >= -6; n--) print digit(a, n, 256),; print
0 0 0 0 1 226 64 201 251 231 108 139 67
; for (n = 1; n >= -12; n++) print digit(10/7, n),; print
; 0 1 4 2 8 5 7 1 4 2 8 5 7 1
; for (n = 1; n >= -12; n++) print digit(10/7, n),; print
; 0 1 4 2 8 5 7 1 4 2 8 5 7 1
; print digit(10/7, -7e1000, 1e6)
428571
@@ -92,7 +92,7 @@ LINK LIBRARY
SEE ALSO
bit
## Copyright (C) 1999-2006 Landon Curt Noll
## Copyright (C) 1999-2006,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

View File

@@ -21,7 +21,7 @@ DESCRIPTION
The builtin function:
display(d)
display(d)
display()
is an alias for:
@@ -96,7 +96,7 @@ LINK LIBRARY
SEE ALSO
config, epsilon, fprintf, printf, strprintf
## Copyright (C) 2004,2018 Landon Curt Noll
## Copyright (C) 2004,2018,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

84
help/dms2d Normal file
View 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/

View File

@@ -38,7 +38,7 @@ DESCRIPTION
(*) NOTE on 'b' / binary/text mode:
The 'b' or fopen binary mode has no effect on POSIX / Linux
The 'b' or fopen binary mode has no effect on POSIX / Linux
/ Un*x-like systems. On those systems a text file is the
same as a binary file (as it should be for any modern-day
operating system). Adding 'b' to an fopen has no effect
@@ -52,9 +52,9 @@ DESCRIPTION
Names of files are subject to ~ expansion just like the C or
Korn shell. For example, the file name:
~/lib/gleet
~/lib/fizzbin
refers to the file 'gleet' under the directory lib located
refers to the file 'fizzbin' under the directory lib located
in your home directory. The file name:
~chongo/was_here
@@ -107,7 +107,7 @@ SEE ALSO
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt,
fpathopen, strerror
## Copyright (C) 1999-2006 Landon Curt Noll
## Copyright (C) 1999-2006,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

View File

@@ -21,7 +21,7 @@ DESCRIPTION
Absolute filenames, and filenames with an implied path are files
that begin with:
/ # absolute path
/ # absolute path
./ # implied path through the current working directory
../ # implied path through the current working directory parent
~ # absolute path going through a home directory
@@ -29,12 +29,12 @@ DESCRIPTION
A search path is a :-separated list of directories used to search for
a filename. For example:
fpathopen("whey", "r", ".:/tmp:/var/tmp:~chongo/pub:~/tmp");
fpathopen("whey", "r", ".:/tmp:/var/tmp:~chongo/pub:~/tmp");
will cause this function to open the first readable file it
files while searching through these paths in order:
./whey
./whey
/tmp/whey
/var/tmp/whey
~chongo/pub/whey
@@ -46,16 +46,16 @@ DESCRIPTION
to open files under the given mode. If the mode allows for
writing and a file can be created, then that file is returned.
This call open "./gleet" for writing if the current directory is
writable, even if "./gleet" did not previously exist:
This call open "./fizzbin" for writing if the current directory is
writable, even if "./fizzbin" did not previously exist:
fpathopen("gleet", "r", ".:/tmp:/var/tmp:~chongo/pub:~/tmp");
fpathopen("fizzbin", "r", ".:/tmp:/var/tmp:~chongo/pub:~/tmp");
This call will likely open (and create if needded) for appending,
the file "/tmp/log" assuming that the user is not allowed to
create files in the previous system directories:
fpathopen("log", "a", "/:/etc:/bin:/usr/bin:/tmp");
fpathopen("log", "a", "/:/etc:/bin:/usr/bin:/tmp");
The CALCPATH search path is taken from the $CALCPATH environment
variable or if no such variable exists, a compiled in default search
@@ -92,7 +92,7 @@ DESCRIPTION
(*) NOTE on 'b' / binary/text mode:
The 'b' or fopen binary mode has no effect on POSIX / Linux
The 'b' or fopen binary mode has no effect on POSIX / Linux
/ Un*x-like systems. On those systems a text file is the
same as a binary file (as it should be for any modern-day
operating system). Adding 'b' to an fopen has no effect
@@ -106,9 +106,9 @@ DESCRIPTION
Names of files are subject to ~ expansion just like the C or
Korn shell. For example, the file name:
~/lib/gleet
~/lib/fizbin
refers to the file 'gleet' under the directory lib located
refers to the file 'fizbin' under the directory lib located
in your home directory. The file name:
~chongo/was_here
@@ -180,7 +180,7 @@ SEE ALSO
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt,
environment, calcpath
## Copyright (C) 2006 Landon Curt Noll
## Copyright (C) 2006,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

117
help/g2gm Normal file
View File

@@ -0,0 +1,117 @@
NAME
g2gm - convert gradians into gradians, and minutes
SYNOPSIS
g2gm(grads, g, m [,rnd])
TYPES
grads real
g null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(grads, 400, rnd)
DESCRIPTION
Convert grads gradians into g gradians, and m minutes.
The return value is a normalized number of gradians, and is equivalent
to the following:
return_value = mod(grads, 400, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 400) or a real value in the interval (-400, 0].
For the default round mode, the return value is in the interval [0, 400).
The g argument will be an integer number of gradians.
The value g will be set as if the following were used:
g = int(return_value);
For some rounding modes, g will be an integer in the interval [0, 400).
For other rounding modes, g will be an integer in the interval (-400, 0].
For the default round mode, g is in the interval [0, 400).
The m argument will be a real number of minutes.
The value m will be set as if the following were used:
tmp = return_value - g;
m = tmp * 60;
free(tmp);
For some rounding modes, m will be a real value in the interval [0, 60).
For other rounding modes, m will be a real value in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
g, and m values:
return_value == g + m/60;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global g, m;
; print g2gm(12.3456,g,m), g, m;
12.3456 12 20.736
; print g2gm(1234.5678,g,m), g, m;
34.5678 34 34.068
; print g2gm(-1234.5678,g,m), g, m;
365.4322 365 25.932
; print g2gm(654.321,grad=,min=), grad, min;
254.321 254 19.26
; print g2gm(-654.321,grad=,min=), grad, min;
145.679 145 40.74
; print g2gm(400.321,grad=,min=), grad, min;
0.321 0 19.26
/* certain non-default rounding modes can return negative values */
; print g2gm(654.321,grad=,min=,1), grad, min;
-145.679 -145 -40.74
; print g2gm(-654.321,grad=,min=,1), grad, min;
-254.321 -254 -19.26
; print g2gm(400.321,grad=,min=,1), grad, min;
-399.679 -399 -40.74
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gms, gm2g, gms2g,
h2hm, h2hms, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

132
help/g2gms Normal file
View File

@@ -0,0 +1,132 @@
NAME
g2gms - convert gradians into gradians, minutes, and seconds
SYNOPSIS
g2gms(grads, g, m, s [,rnd])
TYPES
grads real
g null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(grads, 400, rnd)
DESCRIPTION
Convert grads gradians into g gradians, m minutes, and s seconds.
The return value is a normalized number of gradians, and is equivalent
to the following:
return_value = mod(grads, 400, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 400) or a real value in the interval (-400, 0].
For the default round mode, the return value is in the interval [0, 400).
The g argument will be an integer number of gradians.
The value g will be set as if the following were used:
g = int(return_value);
For some rounding modes, g will be an integer in the interval [0, 400).
For other rounding modes, g will be an integer in the interval (-400, 0].
For the default round mode, g is in the interval [0, 400).
The m argument will be an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - g;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
g, m, and s values:
return_value == g + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global g, m, s;
; print g2gms(12.3456,g,m,s), g, m, s;
12.3456 12 20 44.16
; print g2gms(1234.5678,g,m,s), g, m, s;
34.5678 34 34 4.08
; print g2gms(-1234.5678,g,m,s), g, m, s;
365.4322 365 25 55.92
; print g2gms(654.321,grad=,min=,sec=), grad, min, sec;
254.321 254 19 15.6
; print g2gms(-654.321,grad=,min=,sec=), grad, min, sec;
145.679 145 40 44.4
; print g2gms(400.321,grad=,min=,sec=), grad, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print g2gms(654.321,grad=,min=,sec=,1), grad, min, sec;
-145.679 -145 -40 -44.4
; print g2gms(-654.321,grad=,min=,sec=,1), grad, min, sec;
-254.321 -254 -19 -15.6
; print g2gms(400.321,grad=,min=,sec=,1), grad, min, sec;
-399.679 -399 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gm, gm2g, gms2g,
h2hm, h2hms, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

84
help/gms2g Normal file
View 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
View File

@@ -0,0 +1,117 @@
NAME
h2hm - convert hours into hours, and minutes
SYNOPSIS
h2hm(hours, h, m [,rnd])
TYPES
hours real
h null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(hours, 24, rnd)
DESCRIPTION
Convert hours hours into h hours, and m minutes.
The return value is a normalized number of hours, and is equivalent
to the following:
return_value = mod(hours, 24, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 24) or a real value in the interval (-24, 0].
For the default round mode, the return value is in the interval [0, 24).
The h argument will be an integer number of hours.
The value h will be set as if the following were used:
h = int(return_value);
For some rounding modes, h will be an integer in the interval [0, 24).
For other rounding modes, h will be an integer in the interval (-24, 0].
For the default round mode, h is in the interval [0, 24).
The m argument will be a real number of minutes.
The value m will be set as if the following were used:
tmp = return_value - h;
m = tmp * 60;
free(tmp);
For some rounding modes, m will be a real value in the interval [0, 60).
For other rounding modes, m will be a real value in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
h, and m values:
return_value == h + m/60;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global h, m;
; print h2hm(12.3456,h,m), h, m;
12.3456 12 20.736
; print h2hm(1234.5678,h,m), h, m;
10.5678 10 34.068
; print h2hm(-1234.5678,h,m), h, m;
13.4322 13 25.932
; print h2hm(654.321,hour=,min=), hour, min;
6.321 6 19.26
; print h2hm(-654.321,hour=,min=), hour, min;
17.679 17 40.74
; print h2hm(24.321,hour=,min=), hour, min;
0.321 0 19.26
/* certain non-default rounding modes can return negative values */
; print h2hm(654.321,hour=,min=,1), hour, min;
-17.679 -17 -40.74
; print h2hm(-654.321,hour=,min=,1), hour, min;
-6.321 -6 -19.26
; print h2hm(24.321,hour=,min=,1), hour, min;
-23.679 -23 -40.7
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
h2hms, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

132
help/h2hms Normal file
View File

@@ -0,0 +1,132 @@
NAME
h2hms - convert hours into hours, minutes, and seconds
SYNOPSIS
h2hms(hours, h, m, s [,rnd])
TYPES
hours real
h null-or-real-valued lvalue with assign-to permission
m null-or-real-valued lvalue with assign-to permission
s null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("mod")
return mod(hours, 24, rnd)
DESCRIPTION
Convert hours hours into h hours, m minutes, and s seconds.
The return value is a normalized number of hours, and is equivalent
to the following:
return_value = mod(hours, 24, rnd);
The argument rnd, if not given, defaults to config("mod").
For more information on the effects of rnd, see "help mod".
Depending on the rounding mode, the return could be a real value
in the interval [0, 24) or a real value in the interval (-24, 0].
For the default round mode, the return value is in the interval [0, 24).
The h argument will be an integer number of hours.
The value h will be set as if the following were used:
h = int(return_value);
For some rounding modes, h will be an integer in the interval [0, 24).
For other rounding modes, h will be an integer in the interval (-24, 0].
For the default round mode, h is in the interval [0, 24).
The m argument will be an integer number of minutes.
The value m will be set as if the following were used:
tmp = return_value - h;
tmp_m = tmp * 60;
free(tmp);
m = int(tmp_m);
For some rounding modes, m will be an integer in the interval [0, 60).
For other rounding modes, m will be an integer in the interval (-60, 0].
For the default round mode, m will be in the interval [0, 60).
The s argument will be a real number of seconds.
The value s will be set as if the following were used:
tmp = tmp_m - m;
free(tmp_m);
s = tmp * 60;
free(tmp);
For some rounding modes, s will be a real value in the interval [0, 60).
For other rounding modes, s will be a real value in the interval (-60, 0].
For the default round mode, s will be in the interval [0, 60).
The following shows relationship between the return value and the resulting
h, m, and s values:
return_value == h + m/60 + s/3600;
EXAMPLE
/* if args are undefined, pre-declare them or assign them as args */
; global h, m, s;
; print h2hms(12.3456,h,m,s), h, m, s;
12.3456 12 20 44.16
; print h2hms(1234.5678,h,m,s), h, m, s;
10.5678 10 34 4.08
; print h2hms(-1234.5678,h,m,s), h, m, s;
13.4322 13 25 55.92
; print h2hms(654.321,hour=,min=,sec=), hour, min, sec;
6.321 6 19 15.6
; print h2hms(-654.321,hour=,min=,sec=), hour, min, sec;
17.679 17 40 44.4
; print h2hms(24.321,hour=,min=,sec=), hour, min, sec;
0.321 0 19 15.6
/* certain non-default rounding modes can return negative values */
; print h2hms(654.321,hour=,min=,sec=,1), hour, min, sec;
-17.679 -17 -40 -44.4
; print h2hms(-654.321,hour=,min=,sec=,1), hour, min, sec;
-6.321 -6 -19 -15.6
; print h2hms(24.321,hour=,min=,sec=,1), hour, min, sec;
-23.679 -23 -40 -44.4
LIMITS
none
LINK LIBRARY
none
SEE ALSO
config, d2dm, d2dms, dm2d, dms2d, g2gm, g2gms, gm2g, gms2g,
h2hm, hm2d, hms2d, mod
## Copyright (C) 2021 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2021/09/25 17:24:51
## File existed as early as: 2021
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -18,7 +18,7 @@ DESCRIPTION
takes into account more abstract concepts such as data types.
WARNING: Use of FNV-0 is NOT recommended for general purposes.
Calc uses FNV-0 for internal objects such as associative
Calc uses FNV-0 for internal objects such as associative
arrays as well as other internal processes. Calc
maintains the use of FNV-0 for backwards compatibility.
@@ -47,7 +47,7 @@ LINK LIBRARY
SEE ALSO
ishash, fnv, sha1
## Copyright (C) 1999-2007,2014 Landon Curt Noll
## Copyright (C) 1999-2007,2014,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

84
help/hms2h Normal file
View 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/

View File

@@ -13,7 +13,7 @@ What is calc?
and the calculator will print:
15
15
Calc has the usual collection of arithmetic operators +, -, /, *
as well as ^ (exponentiation), % (modulus) and // (integer divide).
@@ -27,7 +27,7 @@ What is calc?
Notice that calc values can be very large. For example:
2^23209-1
2^23209-1
will print:
@@ -60,7 +60,7 @@ What is calc?
and the calculator prints:
13763753091226345046315979581580902400000000
13763753091226345046315979581580902400000000
The calculator also knows about complex numbers, so that typing:
@@ -69,7 +69,7 @@ What is calc?
will print:
17+6i
17+6i
-55.50474777265624667147+193.9265235748927986537i
The calculator can calculate transcendental functions, and accept and
@@ -81,19 +81,19 @@ What is calc?
prints:
0.8414709848078965066525023216302989996225630607983710656727517099919104
0.8414709848078965066525023216302989996225630607983710656727517099919104
Calc can output values in terms of fractions, octal or hexadecimal.
For example:
config("mode", "fraction"),
config("mode", "fraction"),
(17/19)^23
base(16),
(19/17)^29
will print:
19967568900859523802559065713/257829627945307727248226067259
19967568900859523802559065713/257829627945307727248226067259
0x9201e65bdbb801eaf403f657efcf863/0x5cd2e2a01291ffd73bee6aa7dcf7d1
All numbers are represented as fractions with arbitrarily large

View File

@@ -18,12 +18,12 @@ DESCRIPTION
Note that issq() works on rational values, so:
issq(25/16) == 1
issq(25/16) == 1
If you want to test for prefect square integers, you need to exclude
non-integer values before you test:
isint(curds) && issq(curds)
isint(curds) && issq(curds)
EXAMPLE
; print issq(25), issq(3), issq(0)
@@ -45,7 +45,7 @@ SEE ALSO
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, isstr, istype
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999,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

View File

@@ -17,8 +17,8 @@ DESCRIPTION
If y is an odd prime, then the Legendre symbol (x/y) returns:
(x/y) == 0 x is divisible by y (0 == x % y)
(x/y) == 1 if x is a quadratic residue modulo y
(x/y) == -1 if x is not a quadratic residue modulo y
(x/y) == 1 if x is a quadratic residue modulo y
(x/y) == -1 if x is not a quadratic residue modulo y
Legendre symbol often denoted as (x/y) as if x/y were a fraction.

View File

@@ -2,7 +2,7 @@ NAME
mod - compute the remainder for an integer quotient
SYNOPSIS
mod(x, y, rnd)
mod(x, y [,rnd])
x % y
TYPES
@@ -25,11 +25,11 @@ TYPES
DESCRIPTION
The expression:
x % y
x % y
is equivalent to call:
mod(x, y)
mod(x, y)
The function:
@@ -37,7 +37,7 @@ DESCRIPTION
is equivalent to:
config("mod", rnd), x % y
config("mod", rnd), x % y
except that the global config("mod") value does not change.
@@ -137,7 +137,7 @@ LINK LIBRARY
SEE ALSO
quo, quomod, //, %
## Copyright (C) 1999-2006 Landon Curt Noll
## Copyright (C) 1999-2006,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

View File

@@ -85,7 +85,7 @@
The man command is an alias for the help command. Try:
man jacobi
man jacobi
Only calc help files may be displayed by the help and man commands.

View File

@@ -18,7 +18,7 @@ DESCRIPTION
As a unary operator:
# value
# value
returns the number of 1 bits, or pop-count of the absolute value of
the numerator (abs(num(value))). Therefore when x is a non-negative
@@ -52,7 +52,7 @@ DESCRIPTION
For example, of an executable file contains:
#!/usr/local/src/bin/calc/calc -q -f
#!/usr/local/src/bin/calc/calc -q -f
/* NOTE: The #! above must start in column 1 of the 1st line */
/* The 1st line must end with -f */
## Single # shell comments don't work, use two or more

View File

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

View File

@@ -14,7 +14,7 @@ DESCRIPTION
Generate a pseudo-random number using an subtractive 100 shuffle generator.
We return a pseudo-random number over the half closed interval:
[min,beyond) ((min <= return < beyond))
[min,beyond) ((min <= return < beyond))
By default, min is 0 and beyond is 2^64.

View File

@@ -14,7 +14,7 @@ DESCRIPTION
Generate a pseudo-random number using a Blum-Blum-Shub generator.
We return a pseudo-random number over the half closed interval:
[min,beyond) ((min <= return < beyond))
[min,beyond) ((min <= return < beyond))
By default, min is 0 and beyond is 2^64.
@@ -159,7 +159,7 @@ LINK LIBRARY
SEE ALSO
seed, srand, randbit, isrand, rand, srandom, israndom
## Copyright (C) 1999-2007 Landon Curt Noll
## Copyright (C) 1999-2007,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

View File

@@ -302,7 +302,7 @@ Statements
help round
See:
help builtin
help builtin
for a list of builtin functions.
@@ -321,11 +321,11 @@ Statements
The man command is an alias for the help command. For example:
man jacobi
man jacobi
Only calc help files may be displayed by the help and man commands.
## Copyright (C) 1999-2007,2017 Landon Curt Noll
## Copyright (C) 1999-2007,2017,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

View File

@@ -14,7 +14,7 @@ DESCRIPTION
The stoponerror controls when or if calc stops based on the
number of errors:
n == -1 do not stop
n == -1 do not stop
n == 0 stop on error unless calc was invoked with -c
n > 0 stop when n errors are encountered
@@ -35,7 +35,7 @@ LINK LIBRARY
SEE ALSO
errcount, errmax, errorcodes, iserror, errno, strerror, newerror
## Copyright (C) 2006 Landon Curt Noll
## Copyright (C) 2006,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

View File

@@ -26,6 +26,8 @@ EXAMPLE
strcmp("abc", "abb") == 1
strcmp("abc", "abc") == 0
strcmp("abc", "abd") == -1
strcmp("desk", "Shabisky") == 1
strcmp("Shabisky", "desk") == -1
strcmp("abc\0", "abc") == 1
strcmp("a\0b", "a\0c") == -1
@@ -39,7 +41,7 @@ SEE ALSO
strcat, strcpy, strerror, strlen, strncmp, strncpy, strpos,
strprintf, strscan, strscanf, substr
## Copyright (C) 2006 Ernest Bowen
## Copyright (C) 2006,2021 Ernest Bowen
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -18,7 +18,7 @@ DESCRIPTION
EXAMPLE
; strtolower(" GNU Lesser General Public License");
" gnu lesser general public license"
" gnu lesser general public license"
LIMITS
none.

View File

@@ -18,7 +18,7 @@ DESCRIPTION
EXAMPLE
; strtoupper(" GNU Lesser General Public License");
" GNU LESSER GENERAL PUBLIC LICENSE"
" GNU LESSER GENERAL PUBLIC LICENSE"
LIMITS
none.

View File

@@ -73,11 +73,11 @@ Unexpected
Be careful about the precedence of operators. Note that:
-1 ^ 0.5 == -1
-1 ^ 0.5 == -1
whereas:
(-1) ^ 0.5 == 1i
(-1) ^ 0.5 == 1i
because the above expression in parsed as:
@@ -85,7 +85,7 @@ Unexpected
whereas:
(-1) ^ 0.5 == 1i
(-1) ^ 0.5 == 1i
op= operators associate left to right
@@ -277,7 +277,7 @@ Unexpected
A single # is an calc operator, not a comment. However two or more
##'s in a row is a comment. See "help pound" for more information.
#!/usr/local/src/bin/calc/calc -q -f
#!/usr/local/src/bin/calc/calc -q -f
/* a correct comment */
## another correct comment
@@ -289,7 +289,7 @@ Unexpected
This next example is WRONG:
#!/usr/local/src/bin/calc/calc -q -f
#!/usr/local/src/bin/calc/calc -q -f
# This is not a calc calc comment because it has only a single #
# You must to start comments with ## or /*
@@ -350,7 +350,7 @@ Unexpected
In most interactive shells:
calc 2 * 3
calc 2 * 3
will frequently produce a "Missing operator" error because the '*' is
evaluated as a "shell glob". To avoid this you must quote or escape
@@ -358,11 +358,11 @@ Unexpected
For example, bash / ksh / sh shell users should use:
calc '2 * 3'
calc '2 * 3'
or:
calc 2 \* 3
calc 2 \* 3
or some other form of shell meta-character escaping.
@@ -393,7 +393,7 @@ Unexpected
To avoid this problem, use:
seq 5 | while read i; do calc "($i+3)^2" </dev/null; done
seq 5 | while read i; do calc "($i+3)^2" </dev/null; done
which produces the expected results:

View File

@@ -12,16 +12,16 @@ DESCRIPTION
Calc version strings can be of the form:
x.y.z.w
x.y.z
x.y
x.y.z.w
x.y.z
x.y
where x, y, z, w, v are integers (without leading 0's) and,
t is the literal character 't'.
EXAMPLE
; version()
"2.11.5.4"
"2.11.5.4"
LIMITS
none

View File

@@ -1127,7 +1127,7 @@ addreadset(char *name, char *path, struct stat *sbuf)
* like UNIX inodes. _fullpath also allocated the memory for
* this new longer path name.
*/
{
{
readset[ret].path = _fullpath(NULL, path, MSDOS_MAX_PATH);
if (readset[ret].path == NULL) {
return -1;

View File

@@ -673,7 +673,7 @@ qdigit(NUMBER *q, ZVALUE dpos, ZVALUE base)
/*
* In the first stage, q is expressed as base^k * N/D where
* gcd(D, base) = 1
* K is k as a ZVALUE
* K is k as a ZVALUE
*/
base.sign = 0;
if (ziszero(base) || zisunit(base))

15
qmath.c
View File

@@ -46,10 +46,19 @@ 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_,
NUMBER * initnumbs[] = {&_qzero_, &_qone_, &_qtwo_, &_qthree_,
&_qfour_, &_qten_, &_qnegone_, &_qonehalf_, &_qneghalf_,
&_qonesqbase_, &_qtendivnine_, &_qninedivten_ };
&_qonesqbase_, &_qtendivnine_, &_qninedivten_,
&_qthreesixty, &_qfourhundred, &_qtwentyfour,
NULL /* must be last */
};
/*
@@ -1481,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);

View File

@@ -35,8 +35,6 @@
#endif
#define INITCONSTCOUNT 12 /* number of initnumbs[] pre-defined constants */
/*
* Rational arithmetic definitions.
*/
@@ -276,6 +274,7 @@ 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[];

4
str.c
View File

@@ -939,9 +939,9 @@ stringcaserel(STRING *s1, STRING *s2)
c2++;
}
if ( (tolower(*c1)) > (tolower(*c2)))
return 1;
return 1;
if ( (tolower(*c1)) < (tolower(*c2)))
return -1;
return -1;
if (i1 < i2) return -1;
return (i1 > i2);
}

View File

@@ -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 2 /* minor software version level */
#define MINOR_PATCH 9 /* minor software version level */
/*
@@ -79,7 +79,7 @@ char *Copyright = "\n"
"calc - arbitrary precision calculator\n"
"\n"
"Copyright (C) 1999-2021 David I. Bell, Landon Curt Noll "
"and Ernest Bowen\n"
"and Ernest Bowen\n"
"\n"
"Initial author: David I. Bell\n"
"\n"

View File

@@ -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;

View File

@@ -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};

View File

@@ -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 */