a copy with calc; if not, write to Free Software Foundation, Inc. ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: ilog10,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ilog10,v $ ## ## Under source code control: 1995/10/03 10:40:02 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME isint - whether a value is an integer SYNOPSIS isint(x) TYPES x any, &any return int DESCRIPTION Determine if x is an integer. This function will return 1 if x is integer, 0 otherwise. EXAMPLE ; print isint(2.0), isint(1), isint("0") 1 1 0 ; print isint(2i), isint(1e20), isint(1/3) 0 1 0 LIMITS none LINK LIBRARY none SEE ALSO int, isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile, ishash, isident, islist, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, issq, isstr, istype ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: isint,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/isint,v $ ## ## Under source code control: 1994/10/21 02:21:27 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME acsc - inverse trigonometric cosecant SYNOPSIS acsc(x [,eps]) TYPES x real, with absolute value >= 1 eps nonzero real, defaults to epsilon() return real DESCRIPTION Returns the acsc of x to a multiple of eps with error less in absolute value than .75 * eps. v = acsc(x) is the number in [-pi/2, pi/2] for which csc(v) = x. EXAMPLE ; print acsc(2, 1e-5), acsc(2, 1e-10), acsc(2, 1e-15), acsc(2, 1e-20) .5236 .5235987756 .523598775598299 .52359877559829887308 LIMITS none LINK LIBRARY NUMBER *qacsc(NUMBER *x, NUMBER *eps) SEE ALSO asin, acos, atan, asec, acot, epsilon ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: acsc,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/acsc,v $ ## ## Under source code control: 1995/11/13 03:49:00 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME matsum - sum the elements of a matrix SYNOPSIS matsum(m) TYPES m matrix with any types of elements return number DESCRIPTION Returns the sum of the numeric (real or complex) elements of m. Non-numeric elements are ignored. EXAMPLE ; mat A[2,2] = {1, 2, 3, list(1,2,3)} print matsum(A) 6 LIMITS none LINK LIBRARY void matsum(MATRIX *m, VALUE *vres); SEE ALSO mat, ismat, matdim, matmax, matmin, mattrans, mattrace, matfill, det, inverse, isident, test, config, search, rsearch, reverse, copy, blkcpy, dp, cp, randperm, sort ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: matsum,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/matsum,v $ ## ## Under source code control: 1995/10/25 04:03:46 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME appr - approximate numbers by multiples of a specified number SYNOPSIS appr(x [,y [,z]]) TYPES x real, complex, matrix, list y real z integer return same type as x except that complex x may return a real number DESCRIPTION Return the approximate value of x as specified by a specific error (epsilon) and config ("appr") value. The default value for y is epsilon(). The default value for z is the current value of the "appr" configuration parameter. If y is zero or x is a multiple of y, appr(x,y,z) returns x. I.e., there is no "approximation" - the result represents x exactly. In the following it is assumed y is nonzero and x is not a multiple of y. For real x: appr(x,y,z) is either the nearest multiple of y greater than x or the nearest multiple of y less than x. Thus, if we write a = appr(x,y,z) and r = x - a, then a/y is an integer and abs(r) < abs(y). If r > 0, we say x has been "rounded down" to a; if r < 0, the rounding is "up". For particular x and y, whether the rounding is down or up is determined by z. Only the 5 lowest bits of z are used, so we may assume z has been replaced by its value modulo 32. The type of rounding depends on z as follows: z = 0 round down or up according as y is positive or negative, sgn(r) = sgn(y) z = 1 round up or down according as y is positive or negative, sgn(r) = -sgn(y) z = 2 round towards zero, sgn(r) = sgn(x) z = 3 round away from zero, sgn(r) = -sgn(x) z = 4 round down, r > 0 z = 5 round up, r < 0 z = 6 round towards or from zero according as y is positive or negative, sgn(r) = sgn(x/y) z = 7 round from or towards zero according as y is positive or negative, sgn(r) = -sgn(x/y) z = 8 a/y is even z = 9 a/y is odd z = 10 a/y is even or odd according as x/y is positive or negative z = 11 a/y is odd or even according as x/y is positive or negative z = 12 a/y is even or odd according as y is positive or negative z = 13 a/y is odd or even according as y is positive or negative z = 14 a/y is even or odd according as x is positive or negative z = 15 a/y is odd or even according as x is positive or negative z = 16 to 31 abs(r) <= abs(y)/2; if there is a unique multiple of y that is nearest x, appr(x,y,z) is that multiple of y and then abs(r) < abs(y)/2. If x is midway between successive multiples of y, then abs(r) = abs(y)/2 and the value of a is as given by appr(x, y, z-16). Matrix or List x: appr(x,y,z) returns the matrix or list indexed in the same way as x, in which each element t has been replaced by appr(t,y,z). Complex x: Returns appr(re(x), y, z) + appr(im(x), y, z) * 1i PROPERTIES If appr(x,y,z) != x, then abs(x - appr(x,y,z)) < abs(y). If appr(x,y,z) != x and 16 <= z <= 31, abs(x - appr(x,y,z)) <= abs(y)/2. For z = 0, 1, 4, 5, 16, 17, 20 or 21, and any integer n, appr(x + n*y, y, z) = appr(x, y, z) + n * y. If y is nonzero, appr(x,y,8)/y = an odd integer n only if x = n * y. EXAMPLES ; print appr(-5.44,0.1,0), appr(5.44,0.1,0), appr(5.7,1,0), appr(-5.7,1,0) -5.5 5.4 5 -6 ; print appr(-5.44,-.1,0), appr(5.44,-.1,0), appr(5.7,-1,0), appr(-5.7,-1,0) -5.4 5.5 6 -5 ; print appr(-5.44,0.1,3), appr(5.44,0.1,3), appr(5.7,1,3), appr(-5.7,1,3) -5.5 5.5 6 -6 ; print appr(-5.44,0.1,4), appr(5.44,0.1,4), appr(5.7,1,4), appr(-5.7,1,4) -5.5 5.4 5 -6 ; print appr(-5.44,0.1,6), appr(5.44,0.1,6), appr(5.7,1,6), appr(-5.7,1,6) -5.4 5.4 6 -5 ; print appr(-5.44,-.1,6), appr(5.44,-.1,6), appr(5.7,-1,6), appr(-5.7,-1,6) -5.5 5.5 6 -6 ; print appr(-5.44,0.1,9), appr(5.44,0.1,9), appr(5.7,1,9), appr(-5.7,1,9) -5.5 5.5 5 -5 ; print appr(-.44,0.1,11), appr(.44,0.1,11), appr(5.7,1,11), appr(-5.7,1,11) -.4 .5 5 -6 ; print appr(-.44,-.1,11),appr(.44,-.1,11),appr(5.7,-1,11),appr(-5.7,-1,11) -.5 .4 6 -5 ; print appr(-.44,0.1,12), appr(.44,0.1,12), appr(5.7,1,12), appr(-5.7,1,12) -.4 .5 5 -6 ; print appr(-.44,-.1,12),appr(.44,-.1,12),appr(5.7,-1,12),appr(-5.7,-1,12) -.5 .4 6 -5 ; print appr(-.44,0.1,15), appr(.44,0.1,15), appr(5.7,1,15), appr(-5.7,1,15) -.4 .5 5 -6 ; print appr(-.44,-.1,15),appr(.44,-.1,15),appr(5.7,-1,15),appr(-5.7,-1,15) -.4 .5 5 -6 ; x = sqrt(7-3i, 1e-20) ; print appr(x,1e-5,0), appr(x,1e-5,1), appr(x,1e-5,2), appr(x,1e-6,3) 2.70331-.55488i 2.70332-.55487i 2.70331-.55487i 2.70332-.55488i LIMITS none LINK LIBRARY NUMBER *qmappr(NUMBER *q, NUMBER *e, long R); LIST *listappr(LIST *oldlp, VALUE *v2, VALUE *v3); MATRIX *matappr(MATRIX *m, VALUE *v2, VALUE *v3); SEE ALSO round, bround, cfappr, cfsim ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: appr,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/appr,v $ ## ## Under source code control: 1994/09/25 17:18:21 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME sum - sum, or sum of defined sums SYNOPSIS sum(x_1, x_2, ...) TYPES x_1, x_2, ... any return any DESCRIPTION If an argument x_i is a list with elements e_1, e_2, ..., e_n, it is treated as if x_i were replaced by e_1, e_2, ..., e_n; this may continue recurively if any of the e_j is a list. If an argument x_i is an object of type xx, then x_i is replaced by xx_sum(x_i) if the function xx_sum() has been defined. If the type xx has been defined by: obj xx = {x, y, z}, an appropriate definition of xx_sum(a) is sometimes a.x + a.y + a.z. sum(a) then returns the sum of the elements of a. If x_i has the null value, it is ignored. Thus, sum(a, , b, , c) will return the same as sum(a, b, c). Assuming the above replacements, and that the x_1, x_2, ..., are of types for which addition is defined, sum(x_1, x_2, ...) returns the sum of the arguments. EXAMPLE ; print sum(2), sum(5, 3, 7, 2, 9), sum(3.2, -0.5, 8.7, -1.2, 2.5) 2 26 12.7 ; print sum(list(3,5), 7, list(6, list(7,8), 2)) 38 ; obj point {x, y} ; define point_add(a,b) = obj point = {a.x + b.x, a.y + b.y} ; obj point A = {1, 5} ; obj point B = {1, 4} ; obj point C = {3, 3} ; print sum(A, B, C) obj point {5, 12} ; define point_sum(a) = a.x ; print sum(A, B, C) 5 LIMITS The number of arguments is not to exceed 1024. LINK LIBRARY SEE ALSO max, min, obj, ssq ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: sum,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sum,v $ ## ## Under source code control: 1997/03/10 03:59:59 ## File existed as early as: 1997 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME israndom - whether a value is a Blum generator state SYNOPSIS israndom(x) TYPES x any, &any return int DESCRIPTION Determine if x is a Blum-Blum-Shub pseudo-random number generator state. This function will return 1 if x is a file, 0 otherwise. EXAMPLE ; a = srandom(0) ; print israndom(a), israndom(0); 1 0 LIMITS none LINK LIBRARY none SEE ALSO seed, random, srandom, randombit, isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile, ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, isreal, isrel, issimple, issq, isstr, istype ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: israndom,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/israndom,v $ ## ## Under source code control: 1995/11/11 05:09:41 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME ilog2 - floor of logarithm to base 2 SYNOPSIS ilog2(x) TYPES x nonzero real return integer DESCRIPTION Returns the greatest integer n for which 2^n <= abs(x). EXAMPLE ; print ilog2(1), ilog2(2), ilog2(3), ilog2(4), ilog(1/15) 0 1 1 2 -4 LIMITS none LINK LIBRARY long qilog2(NUMBER *q) SEE ALSO ilog10, ilog ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: ilog2,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ilog2,v $ ## ## Under source code control: 1995/10/03 10:40:02 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME exp - exponential function SYNOPSIS exp(x [,eps]) TYPES x real or complex eps nonzero real, defaults to epsilon() return real or complex DESCRIPTION Approximate the exponential function of x by a multiple of epsilon, the error having absolute value less than 0.75 * eps. If n is a positive integer, exp(x, 10^-n) will usually be correct to the n-th decimal place, which, for large positive x will give many significant figures. EXAMPLE ; print exp(2, 1e-5), exp(2,1e-10), exp(2, 1e-15), exp(2, 1e-20) 7.38906 7.3890560989 7.38905609893065 7.38905609893065022723 ; print exp(30, 1e5), exp(30, 1), exp(30, 1e-10) 10686474600000 10686474581524 10686474581524.4621469905 ; print exp(-20, 1e-5), exp(-20, 1e-10), exp(-20, 1e-15), exp(-20, 1e-20) 0 .0000000021 .000000002061154 .00000000206115362244 ; print exp(1+2i, 1e-5), exp(1+2i, 1e-10) -1.1312+2.47173i -1.1312043838+2.471726672i LIMITS x < 693093 LINK LIBRARY NUMBER *qexp(NUMBER *x, NUMBER *eps) COMPLEX *c_exp(COMPLEX *x, NUMBER *eps) SEE ALSO ln, cosh, sinh, tanh ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: exp,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/exp,v $ ## ## Under source code control: 1995/10/11 04:41:26 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME quo - compute integer quotient of a value by a real number SYNOPSIS quo(x, y, rnd) or x // y TYPES If x is a matrix or list, the returned value is a matrix or list v of the same structure for which each element v[[i]] = quo(x[[i]], y, rnd). If x is an xx-object or x is not an object and y is an xx-object, this function calls the user-defined function xx_quo(x, y, rnd); the types of arguments and returned value are as required by the definition of xx_quo(). If neither x nor y is an object, and x is not a matrix or list: x number (real or complex) y real rnd integer, defaults to config("quo") return number DESCRIPTION If x is real or complex and y is zero, quo(x, y, rnd) returns zero. If x is complex, quo(x, y, rnd) returns quo(re(x), y, rnd) + quo(im(x), y, rnd) * 1i. In the following it is assumed that x is real and y is nonzero. If x/y is an integer quo(x, y, rnd) returns x/y. If x is real, y nonzero and x/y is not an integer, x // y returns one of the two integers v for which abs(x/y - v) < 1. Which integer is returned is controlled by rnd as follows: rnd sign of x/y - v Description of rounding 0 + down, towards minus infinity 1 - up, towards infinity 2 sgn(x/y) towards zero 3 -sgn(x/y) from zero 4 sgn(y) 5 -sgn(y) 6 sgn(x) 7 -sgn(x) 8 to nearest even integer 9 to nearest odd integer 10 even if x/y > 0, otherwise odd 11 odd if x/y > 0, otherwise even 12 even if y > 0, otherwise odd 13 odd if y > 0, otherwise even 14 even if x > 0, otherwise odd 15 odd if x > 0, otherwise even 16-31 to nearest integer when this is uniquely determined; otherwise, when x/y is a half-integer, as if rnd replaced by rnd & 15 NOTE: Blank entries in the table above indicate that the description would be complicated and probably not of much interest. The C language method of modulus and integer division is: config("quomod", 2) config("quo", 2) config("mod", 2) EXAMPLE print quo(11,5,0), quo(11,5,1), quo(-11,5,2), quo(-11,-5,3) 2 3 -2 3 print quo(12.5,5,16), quo(12.5,5,17), quo(12.5,5,24), quo(-7.5,-5,24) 2 3 2 2 LIMITS none LINK LIBRARY void quovalue(VALUE *x, VALUE *y, VALUE *rnd, VALUE *result) NUMBER *qquo(NUMBER *x, NUMBER *y, long rnd) SEE ALSO mod, quomod, //, % ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: quo,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/quo,v $ ## ## Under source code control: 1995/09/18 04:01:44 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME den - denominator of a real number SYNOPSIS den(x) TYPES x real return integer DESCRIPTION For real x, den(x) returns the denominator of x when x is expressed in lowest terms with positive denominator. In calc, real values are actually rational values. Each calc real value can be uniquely expressed as: n / d where: n and d are integers gcd(n,d) == 1 d > 0 The denominator for this n/d is d. EXAMPLE ; print den(7), den(-1.25), den(121/33) 1 4 3 LIMITS none LINK LIBRARY NUMBER *qden(NUMBER *x) SEE ALSO num ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: den,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/den,v $ ## ## Under source code control: 1995/10/05 04:52:26 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME prevcand - previous candidate for primeness SYNOPSIS prevcand(n [,count [, skip [, residue [, modulus]]]]) TYPES n integer count integer with absolute value less than 2^24, defaults to 1 skip integer, defaults to 1 residue integer, defaults to 0 modulus integer, defaults to 1 return integer DESCRIPTION The sign of n is ignored; in the following it is assumed that n >= 0. prevcand(n, count, skip, residue, modulus) returns the greatest positive integer i less than abs(n) expressible as residue + k * modulus, where k is an integer, for which ptest(i,count,skip) == 1, or if there is no such integer i, zero. If n < 2^32, count >= 0, and the returned value i is not zero, i is definitely prime. If n > 2^32, count != 0, and i is not zero, i is probably prime, particularly if abs(count) is greater than 1. With the default argument values, if n > 2, prevcand(n) returns the a probably prime integer i less than n such that every integer between i and n is composite. If skip == 0, the bases used in the probabilistic test are random and then the probability that the returned value is composite is less than 1/4^abs(count). If skip == 1 (the default value) the bases used in the probabilistic test are the first abs(count) primes 2, 3, 5, ... For other values of skip, the bases used are the abs(count) consecutive integer skip, skip + 1, ... If modulus = 0, the only values that may be returned are zero and the value of residue. The latter is returned if it is positive, less than n, and is such that ptest(residue, count, skip) = 1. RUNTIME The runtime for v = prevcand(n, ...) will depend strongly on the number and nature of the integers between n and v. If this number is reasonably large the size of count is largely irrelevant as the compositeness of the numbers between n and v will usually be determined by the test for small prime factors or one pseudoprime test with some base b. If N > 1, count should be positive so that candidates divisible by small primes will be passed over quickly. On the average for random n with large word-count N, the runtime seems to be between roughly K/N^3 some constant K. EXAMPLE ; print prevcand(50), prevcand(2), prevcand(125,-1), prevcand(125,-2) 47 1 113 113 ; print prevcand(100,1,1,1,6), prevcand(100,1,1,-1,6) 97 89 ; print prevcand(100,1,1,2,6), prevcand(100,1,1,4,6), 2 0 ; print prevcand(100,1,1,53,0), prevcand(100,1,1,53,106) 53 53 ; print prevcand(125,1,3), prevcand(125,-1,3), prevcand(125,-2,3) 113 121 113 ; print prevcand(2e60, 1, 1, 31, 1e30) 1999999999999999999999999999914000000000000000000000000000031 LIMITS none LINK LIBRARY int zprevcand(ZVALUE n, long count, long skip, ZVALUE res, ZVALUE mod, ZVALUE *cand) SEE ALSO factor, isprime, lfactor, nextcand, nextprime, prevprime, pfact, pix, ptest ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: prevcand,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/prevcand,v $ ## ## Under source code control: 1996/02/25 00:27:43 ## File existed as early as: 1996 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME ilog - floor of logarithm to specified integer base SYNOPSIS ilog(x, b) TYPES x nonzero real b integer greater than 1 return integer DESCRIPTION Returns the greatest integer n for which b^n <= abs(x). EXAMPLE ; print ilog(2, 3), ilog(8, 3), ilog(8.9, 3), ilog(1/8, 3) 0 1 1 -2 LIMITS x > 0 b > 1 LINK LIBRARY long zlog(ZVALUE x, ZVALUE b) SEE ALSO ilog2, ilog10 ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: ilog,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ilog,v $ ## ## Under source code control: 1995/10/25 04:03:45 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME search - search for an element satisfying a specified condition SYNOPSIS search(a, b [, [c] [, [d] ] ]) TYPES a matrix, list, association or file b string if a is a file, otherwise any c integer, defaults to zero or current file-position d integer, defaults to size(a) or current file-position return nonnegative integer or null value DESCRIPTION Negative values of c and nonpositive values for d are treated as offsets from size(a), i.e. as if c were replaced by size(a) + c, and d by size(a) + d. Any such adjustment is assumed in the following description. For Non-file a: For a matrix, list, or association a, search(a, b, c, d) returns, if it exists, the least index i for which c <= i < d, 0 <= i < size(a), and, if accept() has not been defined, a[[i]] == b, or if accept() has been defined, accept(a[[i]], b) tests as nonzero. The null value is returned if there is no such i. For example, to search for the first a[[i]] > b an appropriate accept() function is given by: define accept(v,b) = (v > b); To restore the original behavior of search(), one may then use define accept(v, b) = (v == b). Since the addresses (rather than values) of a and b are passed, the values of v = x[[i]] and b may be changed during execution of search(a, b, c, d), e.g. if accept(v,b) has been defined by define accept(v,b) = (v > b ? v-- : b++); For a is a file-stream: c defaults to the current file-position if there are just two arguments (a,b) or if there are four arguments as in (a,b, ,d) where d is an integer. Otherwise c defaults to zero. d defaults to the current file-position or size(a) according as the number of arguments (indicated by commas) is four or less than four. If a is a file, a string formed by n successive characters in a is considered to occur at the file position of the first character. E.g. if a has the characters "123456", the string "345" is said to occur at position 2. The file is searched forwards from file-position pos = c for a match with b (not including the terminating '\0'). Only characters with file-positions less than d are considered, so the effective interval for the first-character position pos for a matching string is limited by both c <= pos <= d - strlen(b) and 0 <= pos < size(a) - strlen(b). The function returns pos if a match is found, and the reading position for the stream after the search will then correspond to the position of the terminating '\0' for the string b. The null value is returned if no match is found. If c, d, size(a) and strlen(b) are such that no match is possible, no reading of the file occurs and the current file-position is not changed. In a case where characters are read, the final file-position will be min(d, size(a)) - strlen(b) + 1, i.e. the file will be at the first position where a match is impossible because the specified search region has insufficient remaining characters. EXAMPLE ; L = list(2,"three",4i) ; search(L,"three") 1 ; search(L,"threes") ; search(L, 4i, 4) ; search(L, 4i, 1) 2 ; f = fopen("foo", "w+") ; fputs(f, "This file has 28 characters.") ; rewind(f) ; search(f, "ha") 10 ; ftell(f) 12 ; search(f, "ha") 18 ; search(f, "ha") ; search(f, "ha",) 10 ; search(f, "ha", 12) 18 ; search(f, "ha", -10) 18 ; search(f, "ha", ,) 10 ; search(f, "ha", 11, 19) ; ftell(f) 18 ; search(f, "ha", 11, 20) 18 ; search(f, "ha", 5, 500) 10 LIMITS none LINK LIBRARY none SEE ALSO append, delete, insert, islist, pop, push, remove, rsearch, select, size, assoc, list, mat ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: search,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/search,v $ ## ## Under source code control: 1994/03/19 03:13:21 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ # bindings - default key bindings for calc line editing functions # # Copyright (C) 1999 David I. Bell # # Calc is open software; you can redistribute it and/or modify it under # the terms of the version 2.1 of the GNU Lesser General Public License # 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. # # @(#) $Revision: 30.1 $ # @(#) $Id: bindings,v 30.1 2007/03/16 11:09:54 chongo Exp $ # @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bindings,v $ # # Under source code control: 1993/05/02 20:09:19 # File existed as early as: 1993 # # Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ # NOTE: This facility is ignored if calc was compiled with GNU-readline. # In that case, the standard readline mechanisms (see readline(3)) # are used in place of those found below. map base-map default insert-char ^@ set-mark ^A start-of-line ^B backward-char ^D delete-char ^E end-of-line ^F forward-char ^H backward-kill-char ^J new-line ^K kill-line ^L refresh-line ^M new-line ^N forward-history ^O save-line ^P backward-history ^R reverse-search ^T swap-chars ^U flush-input ^V quote-char ^W kill-region ^Y yank ^? backward-kill-char ^[ ignore-char esc-map map esc-map default ignore-char base-map G start-of-line H backward-history P forward-history K backward-char M forward-char O end-of-line S delete-char g goto-line s backward-word t forward-word d forward-kill-word u uppercase-word l lowercase-word h list-history ^[ flush-input [ arrow-key NAME newerror - create or recall a described error-value SYNOPSIS newerror([str]) TYPES str string return error-value DESCRIPTION If str is not "" and has not earlier been used as an argument for this function, newerror(str) creates a new described error-value so that any future use of newerror(str) with the same str will return the same error-value. If x = newerror(str), both strerror(x) and strerror(iserro(x)) will return str and iserror(x) will return the error code value of the new error. The null cases newerror() and newerror("") are equivalent to newerror("???"). EXAMPLE Note that by default, errmax() is 0 so unless errmax() is increased you will get: ; ba = newerror("curds n' whey"); Error 20000 caused errcount to exceed errmax ; errmax(errcount()+5) 0 ; e1 = newerror("triangle side length <= 0") ; iserror(e1) 20000 ; error(20000) Error 20000 ; strerror(error(20000)) "triangle side length <= 0" ; strerror(e1); "triangle side length <= 0" ; strerror(error(iserror(e1))) "triangle side length <= 0" ; define area(a,b,c) { ;; local s; ;; if (!(a > 0) || !(b > 0) || !(c > 0)) return e1; ;; s = (a + b + c)/2; ;; if (s <= a || s <= b || s <= c) return newerror("Non-triangle sides"); ;; return sqrt(s * (s - a) * (s - b) * (s - c)); ;; } "area" defined ; A = area(8,2,5); ; if (iserror(A)) print strerror(A) : ":", iserror(A); Non-triangle sides: 20001 ; A = area(-3,4,5) ; if (iserror(A)) print strerror(A) : ":", iserror(A); triangle side length <= 0: 20000 LIMITS The number of new described error-values is not to exceed 12767. LINK LIBRARY none SEE ALSO errmax, errcount, error, strerror, iserror, errno, errorcodes, stoponerror ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: newerror,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/newerror,v $ ## ## Under source code control: 1996/04/30 03:39:56 ## File existed as early as: 1996 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME ismat - whether a value is a matrix SYNOPSIS ismat(x) TYPES x any, &any return int DESCRIPTION Determine if x is a matrix. This function will return 1 if x is a matrix, 0 otherwise. EXAMPLE ; mat a[2] ; print ismat(a), ismat(1) 1 0 LIMITS none LINK LIBRARY none SEE ALSO mat, matdim, matfill, matmax, matmin, matsum, mattrans, isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile, ishash, isident, isint, islist, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, issq, isstr, istype ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: ismat,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ismat,v $ ## ## Under source code control: 1994/10/21 02:21:28 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME issq - whether a value is a square SYNOPSIS issq(x) TYPES x real return int DESCRIPTION Determine if x is a square. If there exists integers a, b such that: x == a^2 / b^2 (b != 0) return 1, otherwise return 0. Note that issq() works on rational values, so: 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) EXAMPLE ; print issq(25), issq(3), issq(0) 1 0 1 ; print issq(4/25), issq(-4/25), issq(pi()) 1 0 0 LIMITS none LINK LIBRARY BOOL qissquare(NUMBER *x) BOOL zissquare(ZVALUE x) SEE ALSO isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile, ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, isstr, istype ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: issq,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/issq,v $ ## ## Under source code control: 1994/10/21 02:21:31 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME hash - return the calc hash value SYNOPSIS hash(x_1 [, x_2, x_3, ...]) TYPES x_1, x_1, ... any return integer v, 0 <= v < 2^32 DESCRIPTION Returns a hash value for one or more values of arbitrary types. The calc hash value is based on the core Fowler/Noll/Vo hash known as FNV-1. The return value, however, cannot be used as an FNV hash value because calc's internal function also takes into account more abstract concepts such as data types. See: http://www.isthe.com/chongo/tech/comp/fnv/ information about the Fowler/Noll/Vo (FNV) hash. EXAMPLE ; a = isqrt(2e1000); s = "xyz"; ; hash(a,s) 2378490456 LIMITS The number of arguments is not to exceed 1024. LINK LIBRARY none SEE ALSO ishash, sha1 ## Copyright (C) 1999-2007 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. ## ## @(#) $Revision: 30.2 $ ## @(#) $Id: hash,v 30.2 2007/07/05 17:37:41 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/hash,v $ ## ## Under source code control: 1996/03/12 23:10:01 ## File existed as early as: 1996 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ If you notice something wrong, strange or broken, try rereading: README.FIRST HOWTO.INSTALL BUGS (this file) If that does not help, cd to the calc source directory and try: make check Look at the end of the output, it should say something like: 9998: passed all tests /\../\ 9999: Ending regression tests If it does not, then something is really broken! If you made and modifications to calc beyond the simple Makefile configuration, try backing them out and see if things get better. To be sure that your version of calc is up to date, check out: http://www.isthe.com/chongo/tech/comp/calc/calc-download.html The calc web site is located at: http://www.isthe.com/chongo/tech/comp/calc/index.html =-= If you have tried all of the above and things still are not right, then it may be time to send in a bug report. You can send bug and bug fixes reports to: calc-bugs at asthe dot com [[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]] [[ NOTE: The EMail address uses 'asthe', the web site URL uses 'isthe' ]] Your subject must contain the words: calc bug report You may have additional words in your subject line. When you send your report, please include the following information: * a description of the problem * the version of calc you are using (if you cannot get calc to run, then send us the 4 #define lines from version.c) * if you modified calc from an official patch, send me the mods you made * the type of system you were using * the type of compiler you were using * any compiler warnings or errors that you saw * cd to the calc source directory, and type: make debug > debug.out 2>&1 (sh, ksh, bash users) make debug >& debug.out (csh, tcsh users) and send the contents of the 'debug.out' file. Stack traces from core dumps are useful to send as well. Fell free to use the above address to send in big fixes (in the form of a context diff patch). =-= Known bugs: We are sure some more bugs exist. When you find them, please let us know! See the above for details on how to report and were to EMail your bug reports and hopefully patches to fix them. =-= Problems that have known work-a-rounds: * There is a bug in gcc v4.1.0 that causes calc to fail the regression test. The work-a-round is to compile with gcc v4.1.1 or later. This problems was observed on Fedora 5. =-= mis-features in calc: Some problems are not bugs but rarther mis-features / things that could work better. The following is a list of mis-features that should be addressed and improved someday. * When statement is of the form { ... }, the leading { MUST BE ON THE SAME LINE as the if, for, while or do keyword. This works as expected: if (expr) { ... } However this WILL NOT WORK AS EXPECTED: if (expr) { ... } This needs to be changed. See also "help statement", "help unexpected", and "help todo". * The chi.cal resource file does not work well with odd degrees of freedom. Can someone improve this algorithm? * The intfile.cal resource file reads and writes big or little Endian integers to/from files the hard way. It does NOT use blkcpy. The following code: i = (ord("\n") << 16) | (ord("i") << 8) | ord("H") b = blk() copy(i, b) fd = fopen("file", "w") copy(b, fd); fclose(fd) will write an extra NUL octet to the file. Where as: read intfile i = (ord("\n") << 16) | (ord("i") << 8) | ord("H") be2file(i, "file2") will not. ## Copyright (C) 1999-2007 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: BUGS,v 30.1 2007/03/16 11:09:46 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $ ## ## Under source code control: 1994/03/18 14:06:13 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME hypot - hypotenuse of a right-angled triangle given the other sides SYNOPSIS hypot(x, y [,eps]) TYPES x, y real eps nonzero real return real DESCRIPTION Returns sqrt(x^2 + y^2) to the nearest multiple of eps. The default value for eps is epsilon(). EXAMPLE ; print hypot(3, 4, 1e-6), hypot(2, -3, 1e-6) 5 3.605551 LIMITS none LINK LIBRARY NUMBER *qhypot(NUMBER *q1, *q2, *epsilon) SEE ALSO ltol ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: hypot,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/hypot,v $ ## ## Under source code control: 1995/10/05 04:52:26 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME ltol - "leg to leg", third side of a right-angled triangle with unit hypotenuse, given one other side SYNOPSIS ltol(x, [,eps]) TYPES x real eps nonzero real return real DESCRIPTION Returns sqrt(1 - x^2) to the nearest multiple of eps. The default value for eps is epsilon(). EXAMPLE ; print ltol(0.4, 1e-6), hypot(0.5, 1e-6) .6 .866025 LIMITS abs(x) <= 1 LINK LIBRARY NUMBER *qlegtoleg(NUMBER *q1, *epsilon, BOOL wantneg) SEE ALSO hypot ## Copyright (C) 1999 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: ltol,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ltol,v $ ## ## Under source code control: 1995/10/05 04:52:27 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ If you notice something wrong, strange or broken, try rereading: README.FIRST HOWTO.INSTALL BUGS (this file) If that does not help, cd to the calc source directory and try: make check Look at the end of the output, it should say something like: 9998: passed all tests /\../\ 9999: Ending regression tests If it does not, then something is really broken! If you made and modifications to calc beyond the simple Makefile configuration, try backing them out and see if things get better. To be sure that your version of calc is up to date, check out: http://www.isthe.com/chongo/tech/comp/calc/calc-download.html The calc web site is located at: http://www.isthe.com/chongo/tech/comp/calc/index.html =-= If you have tried all of the above and things still are not right, then it may be time to send in a bug report. You can send bug and bug fixes reports to: calc-bugs at asthe dot com [[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]] [[ NOTE: The EMail address uses 'asthe', the web site URL uses 'isthe' ]] Your subject must contain the words: calc bug report You may have additional words in your subject line. When you send your report, please include the following information: * a description of the problem * the version of calc you are using (if you cannot get calc to run, then send us the 4 #define lines from version.c) * if you modified calc from an official patch, send me the mods you made * the type of system you were using * the type of compiler you were using * any compiler warnings or errors that you saw * cd to the calc source directory, and type: make debug > debug.out 2>&1 (sh, ksh, bash users) make debug >& debug.out (csh, tcsh users) and send the contents of the 'debug.out' file. Stack traces from core dumps are useful to send as well. Fell free to use the above address to send in big fixes (in the form of a context diff patch). =-= Known bugs: We are sure some more bugs exist.