Release calc version 2.11.4t1

This commit is contained in:
Landon Curt Noll
2000-12-15 07:06:11 -08:00
parent ae2a752314
commit 5e098d2adf
52 changed files with 2070 additions and 191 deletions

29
CHANGES
View File

@@ -1,4 +1,25 @@
The following are the changes from calc version 2.11.3t0 to date:
The following are the changes from calc version 2.11.4t1 to date:
Added missing test8600.cal test file.
Fixes cscript files to deal with the -S flag being replaced by
-f and possibly other flags.
The following are the changes from calc version 2.11.3t0 to 2.11.4:
Increased the maximum number of args for functions from 100 to 1024.
Increased calc's internal evaluation stack from 1024 to 2048 args.
Added test8600.cal to the regression suite to test these new limits.
Updated and fixed misc typos in calc/README.
Clarified in the COPYING file that ALL calc source files, both
LGPL covered and exceptions to the LGPL files may be freely used
and distributed.
Added help files or updated for: bernoulli, calc_tty, catalan,
digit, digits, euler, freeeuler, places and sleep.
A collection of 18 patches from Ernest Bowen
<ernie at turing dot une dot edu dot au>:
@@ -167,7 +188,7 @@ The following are the changes from calc version 2.11.3t0 to date:
size of n in digit(x, n, b), for example, digit(1/7, -1e100) which
would not work before can now be handled.
(13) The function, digits(x)m which returns the number of decimal
(13) The function, digits(x), which returns the number of decimal
digits in the integer part of x has been changed so that if abs(x) <
1, it returns 0 rather than 1. This also now applies to digits(x,b).
@@ -4998,8 +5019,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.11 $
## @(#) $Id: CHANGES,v 29.11 2000/06/07 15:51:35 chongo Exp chongo $
## @(#) $Revision: 29.14 $
## @(#) $Id: CHANGES,v 29.14 2000/12/15 14:58:20 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

10
COPYING
View File

@@ -12,8 +12,8 @@ This file is Copyrighted
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
# @(#) $Revision: 29.2 $
# @(#) $Id: COPYING,v 29.2 2000/06/07 14:02:13 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: COPYING,v 29.3 2000/12/14 09:18:06 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
=-=
@@ -167,6 +167,12 @@ Calc copyrights and exception files
top of this file. It is important to note that you may distribute
verbatim copies of this file but you may not modify this file.
Some of these exception files are in the public domain. Other
exception files have non-LGPL Copyrights. In all cases one may
use and distribute these exception files freely. And because one
may freely distribute the LGPL covered files, the entire calc
source may be freely used and distributed.
=-=
General Copyleft and License info

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: addop.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: addop.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
*
* Under source code control: 1990/02/15 01:48:10

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:02:25 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: Makefile,v 29.3 2000/12/15 14:42:52 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
#
# Under source code control: 1991/07/21 05:00:54
@@ -70,7 +70,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal \
test8500.cal
test8500.cal test8600.cal
# These files are found (but not built) in the distribution
#

View File

@@ -1,7 +1,7 @@
Calc standard resource files
----------------------------
To load a reosurce file, try:
To load a resource file, try:
read filename
@@ -59,7 +59,7 @@ files have already been read, the read -once will act as a noop.
The "resource_debug" parameter is intended for controlling the possible
display of special information relating to functions, objects, and
other structures created by instructions in calc resoure files.
other structures created by instructions in calc resource files.
Zero value of config("resource_debug") means that no such information
is displayed. For other values, the non-zero bits which currently
have meanings are as follows:
@@ -274,7 +274,7 @@ pell.cal
pell(D)
Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
Type the solution to pells equation for a particular D.
Type the solution to Pell's equation for a particular D.
pi.cal
@@ -288,7 +288,7 @@ pi.cal
The piforever() prints digits of pi, nicely formatted, for as long
as your free memory space and system up time allows.
The piforever() funcion (written by Klaus Alexander Seistrup
The piforever() function (written by Klaus Alexander Seistrup
<klaus@seistrup.dk>) was inspired by an algorithm conceived by
Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts,
Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990.
@@ -356,7 +356,7 @@ quat.cal
quat_shift(a, b)
Calculate using quaternions of the form: a + bi + cj + dk. In these
functions, quaternians are manipulated in the form: s + v, where
functions, quaternions are manipulated in the form: s + v, where
s is a scalar and v is a vector of size 3.
@@ -386,7 +386,7 @@ randombitrun.cal
randombitrun([run_cnt])
Using randombit(1) to generate a sequence of random bits, determine if
the number and kength of identical bits runs match what is expected.
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the Blum-Blum-Shub generator.
@@ -489,7 +489,7 @@ test1700.cal
value
This resoure files is used by regress.cal to test the read and use keywords.
This resource files is used by regress.cal to test the read and use keywords.
test2600.cal
@@ -514,7 +514,7 @@ test2600.cal
checkresult(x, y, z, a)
test2600(verbose, tnum)
This resoure files is used by regress.cal to test some of builtin functions
This resource files is used by regress.cal to test some of builtin functions
in terms of accuracy and roundoff.
@@ -537,7 +537,7 @@ test2700.cal
iscomsq(x)
test2700(verbose, tnum)
This resoure files is used by regress.cal to test sqrt() for real and
This resource files is used by regress.cal to test sqrt() for real and
complex values.
@@ -625,7 +625,7 @@ test4000.cal
test4000(verbose, tnum) defined
This resource file is used by regress.cal to test ptest, nextcand and
prevcand buildins.
prevcand builtins.
test4100.cal
@@ -677,6 +677,35 @@ test5200.cal
This resource file is used by regress.cal to test the fix of a
global/static bug.
test8400.cal
test8400() defined
This resource file is used by regress.cal to check for quit-based
memory leaks.
test8500.cal
global err_8500
global L_8500
global ver_8500
global old_seed_8500
global cfg_8500
onetest_8500(a,b,rnd) defined
divmod_8500(N, M1, M2, testnum) defined
This resource file is used by regress.cal to the // and % operators.
test8600.cal
global min_8600
global max_8600
global hash_8600
global hmean_8600
This resource file is used by regress.cal to test a change of
allowing up to 1024 args to be passed to a builtin function.
unitfrac.cal
unitfrac(x)
@@ -705,7 +734,7 @@ xx_print.cal
Demo for the xx_print object routines.
## Copyright (C) 1999 David I. Bell and Landon Curt Noll
## Copyright (C) 2000 David I. Bell and Landon Curt Noll
##
## Primary author: Landon Curt Noll
##
@@ -723,8 +752,8 @@ xx_print.cal
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: README,v 29.2 2000/06/07 14:02:25 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: README,v 29.3 2000/12/04 20:11:52 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: regress.cal,v 29.3 2000/06/07 14:02:25 chongo Exp chongo $
* @(#) $Revision: 29.5 $
* @(#) $Id: regress.cal,v 29.5 2000/12/04 20:00:53 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -7538,6 +7538,15 @@ read -once "test8500";
/* 85xx: Ending test_divmod is printed by test8500.cal */
/*
* test_maxargs - test up to 1024 args being passed to a builtin function
*/
print;
print '8600: Starting test_1024args'
read -once "test8600";
/* 86xx: Ending test_1024args is printed by test8600.cal */
/*
* read various calc resource files
*

1406
cal/test8600.cal Normal file

File diff suppressed because it is too large Load Diff

4
calc.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: calc.c,v 29.4 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.5 $
* @(#) $Id: calc.c,v 29.5 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
*
* Under source code control: 1990/02/15 01:48:11

6
calc.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: calc.h,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.5 $
* @(#) $Id: calc.h,v 29.5 2000/12/04 19:32:33 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
*
* Under source code control: 1990/02/15 01:48:31
@@ -62,7 +62,7 @@
#define SYMBOLSIZE 256 /* maximum symbol name size */
#define MAXLABELS 100 /* maximum number of user labels in function */
#define MAXSTRING 1024 /* maximum size of string constant */
#define MAXSTACK 1000 /* maximum depth of evaluation stack */
#define MAXSTACK 2048 /* maximum depth of evaluation stack */
#define MAXFILES 20 /* maximum number of opened files */
#define PROMPT1 "> " /* default normal prompt*/
#define PROMPT2 ">> " /* default prompt inside multi-line input */

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: calcerr.tbl,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
# @(#) $Revision: 29.3 $
# @(#) $Id: calcerr.tbl,v 29.3 2000/07/17 15:35:49 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
#
# Under source code control: 1996/05/23 17:38:44

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: cmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: cmath.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
*
* Under source code control: 1993/07/30 19:42:45

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: codegen.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: codegen.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
*
* Under source code control: 1990/02/15 01:48:13
@@ -162,6 +162,7 @@ getcommands(BOOL toplevel)
}
for (;;) {
if (getfilename(name, &rdonce))
break;
switch (opensearchfile(name,calcpath,
CALCEXT,rdonce)) {
case 0:

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: comfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: comfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
*
* Under source code control: 1990/02/15 01:48:13

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: config.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.4 $
* @(#) $Id: config.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: config.h,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.4 $
* @(#) $Id: config.h,v 29.4 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
*
* Under source code control: 1995/11/01 22:20:17

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.5 $
# @(#) $Id: Makefile,v 29.5 2000/06/07 14:02:59 chongo Exp $
# @(#) $Revision: 29.6 $
# @(#) $Id: Makefile,v 29.6 2000/12/15 14:56:14 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
#
# Under source code control: 1999/11/29 11:10:26
@@ -65,7 +65,7 @@ FMT= fmt
#
# The ${SCRIPT_SRC} is built from ${SCRIPT} and has the .calc extensions.
#
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
# This list is produced by the detaillist rule when no WARNINGS are detected.
# To add a script:
#
# 1) Name the file with a .calc filename extension
@@ -76,15 +76,15 @@ FMT= fmt
#
# make detaillist
#
SCRIPT= mersenne piforever plus simple
SCRIPT= mersenne piforever plus simple square
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc square.calc
# These files are found (but not built) in the distribution
#
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
# These files are used to make (but not built) a calc .a library
# These files are used to make (but not build) a calc .a library
#
CALCLIBLIST=
@@ -92,10 +92,10 @@ CALCLIBLIST=
#
all: ${SCRIPT} ${SCRIPT_SRC} .all
# used by the upper level Makefile to determine of we have done all
# used by the upper level Makefile to determine if we have done all
#
# NOTE: Due to bogus shells found on one common system we must have
# an non-emoty else clause for every if condition. *sigh*
# a non-empty else clause for every if condition. *sigh*
#
.all:
rm -f .all
@@ -245,3 +245,7 @@ simple: simple.calc
rm -f $@
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
${CHMOD} +x $@
square: square.calc
rm -f $@
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
${CHMOD} +x $@

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -S
#!/usr/local/src/cmd/calc/calc -q -s -f
#
# mersenne - print the value of a mersenne number
#
@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: mersenne.calc,v 29.2 2000/06/07 14:02:59 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: mersenne.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
#
# Under source code control: 1999/11/30 00:09:01;
@@ -35,13 +35,19 @@
/*
* parse args
*/
if (argv() != 1) {
if (argv() != 2) {
/* we include the name of this script in the error message */
fprintf(files(2), "usage: %s exp\n", config("program"));
abort "wrong number of args";
}
global n = eval(argv(1));
if (!isint(n) || n <= 0) {
quit "Argument to be a positive integer";
}
/*
* print the decimal value of 2^n-1
*/
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
print "2^": n : "-1 =", 2^n-1;

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -S
#!/usr/local/src/cmd/calc/calc -q -f
#
# piforever - print digits of pi forever (or as long as your mem/cpu allow)
#
@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: piforever.calc,v 29.2 2000/06/07 14:02:59 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: piforever.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
#
# Under source code control: 1999/11/30 00:11:36

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -S
#!/usr/local/src/cmd/calc/calc -q -s -f
#
# plus - add two or more arguments together
#
@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: plus.calc,v 29.2 2000/06/07 14:02:59 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: plus.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
#
# Under source code control: 1999/11/29 10:22:37
@@ -35,19 +35,19 @@
/*
* parse args
*/
if (argv() < 1) {
if (argv() < 2) {
/* we include the name of this script in the error message */
fprintf(files(2), "usage: %s value ...\n", config("program"));
abort "not enough args";
}
/*
* print the sum of the 2 args
* print the sum of the args
*
* Since args are strings, we must eval them before using them numerically.
*/
sum = 0;
for (i=0; i < argv(); ++i) {
for (i=1; i < argv(); ++i) {
sum += eval(argv(i));
}
print sum;

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -S
#!/usr/local/src/cmd/calc/calc -q -f
#
# simple - an example of a simple calc shell script
#
@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.2 $
# @(#) $Id: simple.calc,v 29.2 2000/06/07 14:02:59 chongo Exp $
# @(#) $Revision: 29.3 $
# @(#) $Id: simple.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
#
# Under source code control: 1999/11/29 10:22:37
@@ -32,4 +32,4 @@
/*
* This is an example of a simple calc shell script.
*/
print "The simple calc shell script works!"
print "This simple calc shell script works!"

35
cscript/square.calc Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/local/src/cmd/calc/calc -q -f
#
# sqaure - print the squares of input values
#
# Copyright (C) 2000 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.1 $
# @(#) $Id: square.calc,v 29.1 2000/12/15 14:55:59 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
#
# Under source code control: 2000/12/15 06:52:01
# File existed as early as: 2000
#
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# usage:
# mersenne exp
global s;
while ((s = prompt("")))
print "\t":eval(s)^2;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: c_sysinfo.c,v 29.3 2000/06/07 14:03:03 chongo Exp chongo $
* @(#) $Revision: 29.4 $
* @(#) $Id: c_sysinfo.c,v 29.4 2000/07/17 15:37:12 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
*
* Under source code control: 1997/03/09 23:14:40

6
func.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: func.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.5 $
* @(#) $Id: func.c,v 29.5 2000/12/04 19:32:33 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
*
* Under source code control: 1990/02/15 01:48:15
@@ -162,7 +162,7 @@ static STRINGHEAD newerrorstr;
/*
* arg count definitions
*/
#define IN 100 /* maximum number of arguments */
#define IN 1024 /* maximum number of arguments */
#define FE 0x01 /* flag to indicate default epsilon argument */
#define FA 0x02 /* preserve addresses of variables */

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: Makefile,v 29.3 2000/06/07 14:02:33 chongo Exp chongo $
# @(#) $Revision: 29.5 $
# @(#) $Id: Makefile,v 29.5 2000/12/14 10:33:06 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
#
# Under source code control: 1991/07/23 06:47:57
@@ -140,31 +140,31 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
#
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 bernoulli bit blk blkcpy blkfree blocks bround btrunc \
calclevel ceil cfappr cfsim char cmdbuf cmp comb conj cos cosh \
cot coth count cp csc csch ctime delete den dereference det digit \
digits dp epsilon errcount errmax errno error eval exp fact factor \
fclose fcnt feof ferror fflush fgetc fgetfield fgetline fgets fgetstr \
fib files floor fopen forall fprintf fputc fputs fputstr frac free \
freebernoulli freeglobals freeredc freestatics frem freopen fscan \
fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert \
int inverse iroot isassoc isatty isblk isconfig isdefined iserror \
iseven isfile ishash isident isint islist ismat ismult isnull isnum \
isobj isobjtype isodd isprime isptr isqrt isrand israndom isreal \
isrel issimple issq isstr istype jacobi join lcm lcmfact lfactor ln \
lowbit ltol makelist matdim matfill matmax matmin matsum mattrace \
mattrans max md5 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 power prevcand \
prevprime printf prompt protect ptest push putenv quo quomod rand \
randbit random randombit randperm rcin rcmul rcout rcpow rcsq re \
remove reverse rewind rm root round rsearch runtime saveval scale \
scan scanf search sec sech seed segment select sgn sha sha1 sin \
sinh size sizeof sort sqrt srand srandom ssq str strcat strerror \
strlen strpos strprintf strscan strscanf substr sum swap system \
tail tan tanh test time trunc xor
appr arg argv arrow asec asech asin asinh assign atan atan2 atanh avg \
base bernoulli bit blk blkcpy blkfree blocks bround btrunc calc_tty \
calclevel catalan ceil cfappr cfsim char cmdbuf cmp comb conj cos \
cosh cot coth count cp csc csch ctime delete den dereference det \
digit digits dp epsilon errcount errmax errno error euler eval \
exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \
fgetline fgets fgetstr fib files floor fopen forall fprintf fputc \
fputs fputstr frac free freebernoulli freeeuler freeglobals freeredc \
freestatics frem freopen fscan fscanf fseek fsize ftell gcd gcdrem \
gd getenv hash head highbit hmean hnrmod hypot ilog ilog10 ilog2 \
im indices inputlevel insert int inverse iroot isassoc isatty isblk \
isconfig isdefined iserror iseven isfile ishash isident isint islist \
ismat ismult isnull isnum isobj isobjtype isodd isprime isptr isqrt \
isrand israndom isreal isrel issimple issq isstr istype jacobi join \
lcm lcmfact lfactor ln lowbit ltol makelist matdim matfill matmax \
matmin matsum mattrace mattrans max md5 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 power prevcand prevprime printf prompt protect ptest \
push putenv quo quomod rand randbit random randombit randperm rcin \
rcmul rcout rcpow rcsq re remove reverse rewind rm root round rsearch \
runtime saveval scale scan scanf search sec sech seed segment select \
sgn sha sha1 sin sinh size sizeof sleep sort sqrt srand srandom \
ssq str strcat strerror strlen strpos strprintf strscan strscanf \
substr sum swap system tail tan tanh test time trunc xor
# This list is of files that are clones of DETAIL_HELP files. They are
# built from DETAIL_HELP files.

View File

@@ -22,7 +22,7 @@ DESCRIPTION
Considerable runtime and memory are required for calculating
bernoulli(n) for large even n. For n = 1000, the numerator has
1779 digits, the denominator 9 digits.
1779 digits, the denominator 9 digits.
The memory used to store calculated bernoulli numbers is freed by
freebernoulli().
@@ -35,11 +35,11 @@ EXAMPLE
LIMITS
n < 2^31-1
LINK LIBRARY
LIBRARY
NUMBER *qbernoulli(long n)
SEE ALSO
euler, freebernoulli, catalan, comb, fact, perm
euler, catalan, comb, fact, perm
## Copyright (C) 2000 Ernest Bowen
##
@@ -57,11 +57,11 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
## @(#) $Revision: 29.3 $
## @(#) $Id: bernoulli,v 29.3 2000/12/14 10:32:24 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/bernoulli,v $
##
## Under source code control: 2000/07/13
## Under source code control: 2000/07/13 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

52
help/calc_tty Normal file
View File

@@ -0,0 +1,52 @@
NAME
calc_tty - restore normal input conditions for interactive use
SYNOPSIS
calc_tty()
TYPES
return none if appears to be successful, error-value otherwise
DESCRIPTION
This may enable a return to normal operation if abnormal activity
results from a change of one or more terminal characteristics, as
may occur when activity is resumed by an fg command after a ctrl-Z
interrupt, or by any of the three commands:
> !stty echo
> !stty -cbreak
> !stty echo -cbreak
EXAMPLE
> calc_tty();
LIBRARY
none
SEE ALSO
none
## Copyright (C) 2000 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
## 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.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: calc_tty,v 29.1 2000/12/14 10:31:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/calc_tty,v $
##
## Under source code control: 2000/12/14 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

63
help/catalan Normal file
View File

@@ -0,0 +1,63 @@
NAME
catalan - Catalan number
SYNOPSIS
catalan(n)
TYPES
n integer
return integer
DESCRIPTION
If n >= 0, this returns the Catalan number for index n:
catalan(n) = comb(2*n,n)/(n + 1)
Zero is returned for negative n.
The Catalan numbers occur in solutions of several elementary
combinatorial problems, e.g. for n >= 1, catalan(n) is the number of
ways of using parentheses to express a product of n + 1 letters in
terms of binary products; it is the number of ways of dissecting a
convex polygon with n + 2 sides into triangles by nonintersecting
diagonals; it is the number of integer-component-incrementing paths
from (x,y) = (0,0) to (x,y) = (n,n) for which always y <= x.
EXAMPLE
> print catalan(2), catalan(3), catalan(4), catalan(20)
2 5 14 6564120420
LIMITS
none
LINK LIBRARY
NUMBER *qcatalan(NUMBER *n)
SEE ALSO
comb, fact, perm
## Copyright (C) 2000 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
## 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.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: catalan,v 29.1 2000/12/14 10:31:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/catalan,v $
##
## Under source code control: 2000/12/14 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -207,9 +207,9 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
## @(#) $Revision: 29.3 $
## @(#) $Id: define,v 29.3 2000/07/17 15:36:26 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/define,v $
##
##
## Under source code control: 1991/07/21 04:37:18

View File

@@ -1,38 +1,93 @@
NAME
digit - digit at specified position in a decimal representation
digit - digit at specified position in a "decimal" representation
SYNOPSIS
digit(x, y)
digit(x, n [, b])
TYPES
x real
y integer
n integer
b integer >= 2, default = 10
return integer
DESCRIPTION
By extending the digits on the left, and if necessary, the digits
on the right, by infinite strings of zeros, abs(x) may be considered
to have the decimal representation:
... d_2 d_1 d_0.d_-1 d_-2 ...
d(x,n,b) returns the digit with index n in a standard base-b "decimal"
representation of x, which may be described as follows:
For an arbitrary base b >= 2, following the pattern of decimal (base 10)
notation in elementary arithmetic, a base-b "decimal" representation of
a positive real number may be considered to be specified by a finite or
infinite sequence of "digits" with possibly a "decimal" point
to indicate where the fractional part of the representation begins.
Just as the digits for base 10 are the integers 0, 1, 2, ..., 9, the
digits for a base-b representation are the integers d for which
0 <= d < b. The index for a digit position is the count, positively to
the left, of the number from the "units" position immediately to the
left of the "decimal" point; the digit d_n at position n contributes
additively d_n * b^n to the value of x. For example,
d_2 d_1 d_0 . d_-1 d_-2
represents the number
d_2 * b^2 + d_1 * b + d0 + d_-1 * b^-1 + d_-2 * b^-2
The sequence of digits has to be infinite if den(x) has a prime factor
which is not a factor of the base b. In cases where the representation
may terminate, the digits are considered to continue with an infinite
string of zeros rather than the other possibility of an infinite
sequence of (b - 1)s. Thus, for the above example, d_n = 0 for
n = -3, -4, ... Similarly, a representation may be considered to
continue with an infinite string of zeros on the left, so that in the
above example d_n = 0 also for n >= 3.
For negative x, digit(x,n,b) is given by digit(abs(x),n,b); the
standard "decimal" representation of this x is a - sign followed by
the representation of abs(x).
In calc, the "real" numbers are all rational and for these the
digits following the decimal point eventually form a recurring sequence.
With base-b digits for x as explained above, the integer whose base-b
representation is
b_n+k-1 b_n_k-2 ... b_n,
i.e. the k digits with last digit b_n, is given by
digit(b^-r * x, q, b^k)
if r and q satisfy n = q * b + r.
digit(x,y) then returns the digit d_y.
EXAMPLE
> x = 12.34
> print digit(x,2), digit(x,1), digit(x,0), digit(x,-1), digit(x,-2)
0 1 2 3 4
> a = 123456.789
> for (n = 6; n >= -6; n++) print digit(a, n),; print
0 1 2 3 4 5 6 7 8 9 0 0 0
> x = 10/7
> print digit(x,1), digit(x,0), digit(x,-1), digit(x,-2), digit(x,-3)
0 1 4 2 8
> for (n = 6; n >= -6; n--) print digit(a, n, 100),; print
0 0 0 0 12 34 56 78 90 0 0 0 0
> 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
> print digit(10/7, -7e1000, 1e6)
428571
LIMITS
If x is not an integer, y > -2^31
The absolute value of the integral part of x is assumed to be less
than 2^2^31, ensuring that digit(x, n, b) will be zero if n >= 2^31.
The size of negative n is limited only by the capacity of the computer
being used.
LINK LIBRARY
long qdigit(NUMBER *x, long y)
NUMBER * qdigit(NUMBER *q, ZVALUE dpos, ZVALUE base)
SEE ALSO
bit
@@ -53,8 +108,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: digit,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: digit,v 29.3 2000/12/14 10:32:24 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digit,v $
##
## Under source code control: 1995/10/03 10:40:01

View File

@@ -1,30 +1,36 @@
NAME
digits - return number of digits in an integer or integer part
digits - return number of "decimal" digits in an integral part
SYNOPSIS
digits(x)
digits(x [,b])
TYPES
x real
b integer >= 2, defaults to 10
return integer
DESCRIPTION
For real x, digits(x) returns the number of digits in the decimal
representation of int(abs(x)). If x >= 1, digits(x) = 1 + ilog10(x).
Returns the least non-negative integer n for which abs(x) < b^n.
digits(x, b) = 0 if and only if abs(x) < 1.
For real x with absolute value >= 1, digits(x, b) is the number
of digits in the standard base-b "decimal" representation of int(abs(x));
this is also given by 1 + ilog(x, b).
EXAMPLE
> print digits(0), digits(0.0123), digits(3.7), digits(-27), digits(-99.7)
1 1 1 2 2
0 0 1 2 2
LIMITS
none
LINK LIBRARY
long qdigits(NUMBER *x)
long qdigits(NUMBER *q, ZVALUE base)
SEE ALSO
places
digit, places
## Copyright (C) 1999 Landon Curt Noll
##
@@ -42,8 +48,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: digits,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: digits,v 29.3 2000/12/14 10:32:24 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digits,v $
##
## Under source code control: 1995/10/03 10:40:01

63
help/euler Normal file
View File

@@ -0,0 +1,63 @@
NAME
euler - Euler number
SYNOPSIS
euler(n)
TYPES
n integer, n <= 1000000 if even
return integer
DESCRIPTION
Returns the Euler number with index n, i.e. the coefficient E_n in
the expansion
sech(t) = Sigma E_n * t^n/n!
When euler(n) is computed for positive even n, the values for
n and smaller positive even indices are stored in a table so that
a later call to euler(k) with 0 <= k <= n will be executed quickly.
If euler(k) is called with negative k, zero is returned and the
memory used by the table iu freed.
Considerable runtime and memery are required for calculating
euler(n) for large even n.
EXAMPLE
> for (n = 0; n <= 6; n++) print euler(n),; print;
1 0 -1 0 5 0 -61
LIMITS
none
LINK LIBRARY
NUMBER *qeuler(long n)
SEE ALSO
bernoulli, bell, catalan, comb, fact, perm
## Copyright (C) 2000 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
## 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.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: euler,v 29.1 2000/12/14 10:31:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/euler,v $
##
## Under source code control: 2000/12/14 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -40,8 +40,8 @@ SEE ALSO
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
## @(#) $Id: freebernoulli,v 29.2 2000/07/17 15:36:26 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/freebernoulli,v $
##
## Under source code control: 2000/07/13
## File existed as early as: 2000

49
help/freeeuler Normal file
View File

@@ -0,0 +1,49 @@
NAME
freeeuler - free stored Euler numbers
SYNOPSIS
freeeuler()
TYPES
return none
DESCRIPTION
The memory used to store calculated Euler numbers is freed by
freeeuler().
EXAMPLE
> freeeuler();
LIMITS
none
LINK LIBRARY
void qfreeeuler(void);
SEE ALSO
euler, bernoulli, freebernoulli
## Copyright (C) 2000 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
## 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.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: freeeuler,v 29.1 2000/12/14 10:31:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/freeeuler,v $
##
## Under source code control: 2000/12/14 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -36,7 +36,7 @@ ABORT opcodes
various places in the opcodes for evaluation of command lines
and functions defined by "define ... { ... }" commands. In the
following, config("trace") has been set equal to 8 so that opcodes
are displayed when a function is defined. The function f(x)
are displayed when a function is defined. The function f(x)
evaluates x + (x - 1) + (x - 2) + ... until a zero term is
encountered. If f() is called with a negative or fractional x,
the calculation is never completed and to stop it, an interruption
@@ -64,7 +64,7 @@ ABORT opcodes
(The line number following DEBUG refers to the line in the file
from which the definition is read.) If an attempt is made to
evaluate f(-1), the effect of the DEBUG at opcode 6 ensures that
a single SIGINT will stop the calculation at a start of
a single SIGINT will stop the calculation at a start of
{s += x--} loop. In interactive mode, with ^C indicating
input of ctrl-C, the displayed output is as in:
@@ -115,8 +115,8 @@ ABORT opcodes
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: interrupt,v 29.2 2000/06/07 14:02:33 chongo Exp chongo $
## @(#) $Revision: 29.4 $
## @(#) $Id: interrupt,v 29.4 2000/07/17 15:38:52 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/interrupt,v $
##
## Under source code control: 1991/07/21 04:37:21

View File

@@ -1,34 +1,41 @@
NAME
places - return number of decimal places
places - return number of "decimal" places in a fractional part
SYNOPSIS
places(x)
places(x [,b])
TYPES
x real
b integer >= 2, defaults to 10
return integer
DESCRIPTION
If x has a finite decimal representation (with nonzero last digit),
places(x) returns the number of digits after the decimal point in this
representation; this is the least non-negative integer n for which
10^n * x is an integer.
Returns the least non-negative integer n for which b^n * x is an
integer, or -1 if there is no such integer.
If x does not have a finite decimal representation, places(x) returns -1.
places(x,b) = 0 if and only if x is an integer.
places(x,b) = n > 0 if and only if the fractional part of abs(x)
has a finite base-b "decimal" representation with n digits of which
the last digit is nonzero. This occurs if and only if every prime
factor of den(x) is a factor of b.
EXAMPLE
> print places(3), places(0.0123), places(3.70), places(1e-10), places(3/7)
0 4 1 10 -1
> print places(0.0123, 2), places(.625, 2), places(.625, 8)
-1 3 1
LIMITS
none
LINK LIBRARY
long qplaces(NUMBER *x)
long qplaces(NUMBER *q, ZVALUE base)
SEE ALSO
digits
digit, digits
## Copyright (C) 1999 Landon Curt Noll
##
@@ -46,8 +53,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: places,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: places,v 29.3 2000/12/14 10:32:24 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/places,v $
##
## Under source code control: 1995/10/03 10:40:02

View File

@@ -283,8 +283,8 @@ For more information use the following calc commands:
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.3 $
## @(#) $Id: script,v 29.3 2000/06/07 14:02:33 chongo Exp chongo $
## @(#) $Revision: 29.4 $
## @(#) $Id: script,v 29.4 2000/07/17 15:36:26 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/script,v $
##
## Under source code control: 1999/11/30 05:29:48

68
help/sleep Normal file
View File

@@ -0,0 +1,68 @@
NAME
sleep - suspend operation for a specified time
SYNOPSIS
sleep([n])
TYPES
n non-negative real, defaults to 1
return integer or null value
DESCRIPTION
This uses the C-library sleep (if n is integral) or usleep (for
non-integral n) to suspend operation for n seconds. If n is an
integer and the sleep is stopped by an interruption, the number
of seconds remaining is returned.
One kind of use is to slow down output to permit easier reading of
results, as in:
> for (i = 0; i < 100; i++) {
print sqrt(i);
sleep(1/2);
}
The following illustrates what happens if ctrl-C is hit 5 seconds
after the first command:
> print sleep(20)
[Abort level 1]
15
>
EXAMPLE
> sleep(1/3);
> sleep(20);
LIBRARY
none
SEE ALSO
none
## Copyright (C) 2000 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
## 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.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: sleep,v 29.1 2000/12/14 10:31:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sleep,v $
##
## Under source code control: 2000/12/14 01:33:00
## File existed as early as: 2000
##
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: input.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: input.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/input.c,v $
*
* Under source code control: 1990/02/15 01:48:16

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: lib_calc.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.4 $
* @(#) $Id: lib_calc.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.c,v $
*
* Under source code control: 1996/06/17 18:06:19

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: opcodes.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: opcodes.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.c,v $
*
* Under source code control: 1990/02/15 01:48:19

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: qfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: qfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qfunc.c,v $
*
* Under source code control: 1990/02/15 01:48:20

4
qio.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: qio.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: qio.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qio.c,v $
*
* Under source code control: 1993/07/30 19:42:46

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: qmath.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: qmath.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.c,v $
*
* Under source code control: 1990/02/15 01:48:21

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: qmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: qmath.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.h,v $
*
* Under source code control: 1993/07/30 19:42:47

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: token.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.4 $
* @(#) $Id: token.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/token.c,v $
*
* Under source code control: 1990/02/15 01:48:25

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: value.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: value.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.c,v $
*
* Under source code control: 1990/02/15 01:48:25

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: value.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: value.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.h,v $
*
* Under source code control: 1993/07/30 19:42:47

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.14 $
* @(#) $Id: version.c,v 29.14 2000/07/14 07:20:42 chongo Exp chongo $
* @(#) $Revision: 29.17 $
* @(#) $Id: version.c,v 29.17 2000/12/15 14:58:20 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -42,8 +42,8 @@ static char *program;
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 3 /* patch level or 0 if no patch */
#define MINOR_PATCH "0" /* test number or empty string if no patch */
#define MAJOR_PATCH 4 /* patch level or 0 if no patch */
#define MINOR_PATCH "1" /* test number or empty string if no patch */
/*
* calc version constants

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: zfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: zfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zfunc.c,v $
*
* Under source code control: 1990/02/15 01:48:27

4
zio.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: zio.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: zio.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zio.c,v $
*
* Under source code control: 1993/07/30 19:42:48

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: zmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
* @(#) $Revision: 29.3 $
* @(#) $Id: zmath.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zmath.h,v $
*
* Under source code control: 1993/07/30 19:42:48

7
zmod.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: zmod.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: zmod.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zmod.c,v $
*
* Under source code control: 1991/05/22 23:03:55
@@ -544,10 +544,9 @@ zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res)
*res = _zero_;
return;
}
if (zisone(z1) && ziseven(z2)) {
if (zisone(z1)) {
if (ztmp.len)
zfree(ztmp);
zfree(z1);
*res = _one_;
return;
}