mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fde724aa2d | ||
|
e411a3e6bf | ||
|
7db81649b0 | ||
|
08fe6f13f4 | ||
|
e11d159c81 | ||
|
dfd66be871 | ||
|
27f977b545 | ||
|
2ca6e789ca | ||
|
ff8f921ebc | ||
|
005b78227a | ||
|
b7a42a9d3d | ||
|
3d1e938cb6 | ||
|
8b98a7c1f6 | ||
|
dbf5acf5e8 | ||
|
5fe5ab1c4b | ||
|
e0cd9bb3db | ||
|
f0f6171354 | ||
|
94861cc6d2 | ||
|
286233e28f | ||
|
99ac7836aa | ||
|
6c0c8e0ef6 | ||
|
8aa5f140bf | ||
|
2fcb9a5995 | ||
|
8b018b697d | ||
|
0e269ecd67 | ||
|
a640bc4656 | ||
|
62a95499ef | ||
|
9e92d4a35a |
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '41 1 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -94,6 +94,7 @@ sample_rand
|
||||
tags
|
||||
terminal.h
|
||||
ver_calc
|
||||
win32/
|
||||
|
||||
# other commonly excluded patterns
|
||||
#
|
||||
|
136
CHANGES
136
CHANGES
@@ -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:
|
||||
@@ -191,6 +230,25 @@ The following are the changes from calc version 2.14.0.0 to date:
|
||||
; 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:
|
||||
|
||||
@@ -809,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.
|
||||
|
||||
@@ -868,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.
|
||||
|
||||
@@ -947,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.
|
||||
@@ -991,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.
|
||||
|
||||
@@ -1160,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
|
||||
|
||||
@@ -1216,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.
|
||||
|
||||
@@ -1373,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:
|
||||
|
||||
@@ -1438,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
|
||||
@@ -1453,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.
|
||||
@@ -1461,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.
|
||||
@@ -1497,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
|
||||
@@ -1651,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
|
||||
@@ -1665,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 %
|
||||
@@ -1846,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"
|
||||
|
||||
@@ -1896,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
|
||||
@@ -2011,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
|
||||
|
||||
@@ -2106,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.
|
||||
@@ -2129,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.
|
||||
|
||||
@@ -2137,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
|
||||
@@ -2176,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
|
||||
@@ -2281,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.
|
||||
@@ -2301,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
|
||||
@@ -2392,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
|
||||
@@ -2569,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.
|
||||
@@ -2650,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.
|
||||
|
||||
@@ -2817,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.
|
||||
|
||||
@@ -2930,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:
|
||||
|
||||
|
26
Makefile
26
Makefile
@@ -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
|
||||
|
@@ -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.3
|
||||
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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Dear calc user on a Windoz based system,
|
||||
Dear calc user on a Windows based system,
|
||||
|
||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
See also the README file.
|
||||
|
21
SECURITY.md
Normal file
21
SECURITY.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 5.1.x | :white_check_mark: |
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use this section to tell people how to report a vulnerability.
|
||||
|
||||
Tell them where to go, how often they can expect to get an update on a
|
||||
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||
declined, etc.
|
22
cal/Makefile
22
cal/Makefile
@@ -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.
|
||||
#
|
||||
|
38
cal/README
38
cal/README
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -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
641
cal/palindrome.cal
Normal 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;
|
||||
}
|
@@ -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){
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
13
const.c
13
const.c
@@ -44,16 +44,16 @@ initconstants(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
consttable = (NUMBER **) malloc(sizeof(NUMBER *) * CONSTALLOCSIZE);
|
||||
consttable = (NUMBER **) calloc(sizeof(NUMBER *), CONSTALLOCSIZE);
|
||||
if (consttable == NULL) {
|
||||
math_error("Unable to allocate constant table");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
for (i = 0; i < INITCONSTCOUNT; i++)
|
||||
for (i = 0; initnumbs[i] != NULL; i++) {
|
||||
consttable[i] = initnumbs[i];
|
||||
consttable[INITCONSTCOUNT] = NULL; /* firewall */
|
||||
constcount = INITCONSTCOUNT;
|
||||
constavail = CONSTALLOCSIZE - INITCONSTCOUNT;
|
||||
}
|
||||
constcount = i-1;
|
||||
constavail = CONSTALLOCSIZE - constcount;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,9 @@ addqconstant(NUMBER *q)
|
||||
tp = consttable;
|
||||
for (index = 0; index < constcount; index++, tp++) {
|
||||
t = *tp;
|
||||
if (t == NULL) { /* paranoia */
|
||||
break;
|
||||
}
|
||||
if (t->links == 0) {
|
||||
if (!havefirst) {
|
||||
havefirst = TRUE;
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -496,7 +496,7 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.14.0.3
|
||||
VERSION= 2.14.0.9
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
|
@@ -496,7 +496,7 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.14.0.3
|
||||
VERSION= 2.14.0.9
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
56
help.c
56
help.c
@@ -29,6 +29,7 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include "calc.h"
|
||||
#include "conf.h"
|
||||
@@ -262,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) {
|
||||
|
||||
@@ -276,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 */
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
10
help/config
10
help/config
@@ -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"
|
||||
|
@@ -31,7 +31,7 @@ DESCRIPTION
|
||||
|
||||
The value d will be set as if the following were used:
|
||||
|
||||
d = int(return_value);
|
||||
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].
|
||||
@@ -52,7 +52,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
d, and m values:
|
||||
|
||||
return_value == d + m/60;
|
||||
return_value == d + m/60;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -32,7 +32,7 @@ DESCRIPTION
|
||||
|
||||
The value d will be set as if the following were used:
|
||||
|
||||
d = int(return_value);
|
||||
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].
|
||||
@@ -67,7 +67,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
d, m, and s values:
|
||||
|
||||
return_value == d + m/60 + s/3600;
|
||||
return_value == d + m/60 + s/3600;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -31,7 +31,7 @@ DESCRIPTION
|
||||
|
||||
The value g will be set as if the following were used:
|
||||
|
||||
g = int(return_value);
|
||||
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].
|
||||
@@ -52,7 +52,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
g, and m values:
|
||||
|
||||
return_value == g + m/60;
|
||||
return_value == g + m/60;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -32,7 +32,7 @@ DESCRIPTION
|
||||
|
||||
The value g will be set as if the following were used:
|
||||
|
||||
g = int(return_value);
|
||||
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].
|
||||
@@ -67,7 +67,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
g, m, and s values:
|
||||
|
||||
return_value == g + m/60 + s/3600;
|
||||
return_value == g + m/60 + s/3600;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -31,7 +31,7 @@ DESCRIPTION
|
||||
|
||||
The value h will be set as if the following were used:
|
||||
|
||||
h = int(return_value);
|
||||
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].
|
||||
@@ -52,7 +52,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
h, and m values:
|
||||
|
||||
return_value == h + m/60;
|
||||
return_value == h + m/60;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -32,7 +32,7 @@ DESCRIPTION
|
||||
|
||||
The value h will be set as if the following were used:
|
||||
|
||||
h = int(return_value);
|
||||
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].
|
||||
@@ -67,7 +67,7 @@ DESCRIPTION
|
||||
The following shows relationship between the return value and the resulting
|
||||
h, m, and s values:
|
||||
|
||||
return_value == h + m/60 + s/3600;
|
||||
return_value == h + m/60 + s/3600;
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
@@ -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
|
||||
|
14
help/intro
14
help/intro
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
||||
|
8
help/mod
8
help/mod
@@ -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
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -18,7 +18,7 @@ DESCRIPTION
|
||||
|
||||
EXAMPLE
|
||||
; strtolower(" GNU Lesser General Public License");
|
||||
" gnu lesser general public license"
|
||||
" gnu lesser general public license"
|
||||
|
||||
LIMITS
|
||||
none.
|
||||
|
@@ -18,7 +18,7 @@ DESCRIPTION
|
||||
|
||||
EXAMPLE
|
||||
; strtoupper(" GNU Lesser General Public License");
|
||||
" GNU LESSER GENERAL PUBLIC LICENSE"
|
||||
" GNU LESSER GENERAL PUBLIC LICENSE"
|
||||
|
||||
LIMITS
|
||||
none.
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -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
|
||||
|
2
input.c
2
input.c
@@ -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;
|
||||
|
2
qfunc.c
2
qfunc.c
@@ -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))
|
||||
|
8
qmath.c
8
qmath.c
@@ -53,10 +53,12 @@ NUMBER _qfourhundred = { { _fourhundredval_, 1, 0 },
|
||||
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_,
|
||||
&_qthreesixty, &_qfourhundred, &_qtwentyfour };
|
||||
&_qthreesixty, &_qfourhundred, &_qtwentyfour,
|
||||
NULL /* must be last */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@@ -1488,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);
|
||||
|
2
qmath.h
2
qmath.h
@@ -35,8 +35,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define INITCONSTCOUNT 15 /* number of initnumbs[] pre-defined constants */
|
||||
|
||||
/*
|
||||
* Rational arithmetic definitions.
|
||||
*/
|
||||
|
4
str.c
4
str.c
@@ -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);
|
||||
}
|
||||
|
@@ -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 3 /* 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"
|
||||
|
4
zfunc.c
4
zfunc.c
@@ -1034,7 +1034,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
|
||||
}
|
||||
needw = FALSE;
|
||||
}
|
||||
g = *a0 * w;
|
||||
g = (FULL) (*a0 * w);
|
||||
if (h < BASEB) {
|
||||
g &= (1 << h) - 1;
|
||||
} else {
|
||||
@@ -1044,7 +1044,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
|
||||
g = 1;
|
||||
}
|
||||
} else {
|
||||
g = (HALF) *a0 * w;
|
||||
g = (FULL) (*a0 * w);
|
||||
}
|
||||
a = a0;
|
||||
b = b0;
|
||||
|
Reference in New Issue
Block a user