From b8cc0555e4a6f0b2c271a0ac7e79b336600ab693 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 30 Oct 2007 14:21:51 +0000 Subject: Clear up what's going on a bit more. [Bug 1811803] --- ChangeLog | 3 +++ doc/expr.n | 28 +++++++++++++-------- doc/mathfunc.n | 77 +++++++++++++++++++++++++++++----------------------------- 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 155ed03..994a152 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-10-30 Donal K. Fellows + * doc/expr.n, doc/mathfunc.n: Improve documentation to try to make + clearer what is going on. + * doc/interp.n: Shorten the basic descriptive text for some interp subcommands so Solaris nroff doesn't truncate them. [Bug 1822268] diff --git a/doc/expr.n b/doc/expr.n index a64431c..17b83e6 100644 --- a/doc/expr.n +++ b/doc/expr.n @@ -6,7 +6,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: expr.n,v 1.29 2007/10/29 11:28:50 dkf Exp $ +'\" RCS: @(#) $Id: expr.n,v 1.30 2007/10/30 14:21:52 dkf Exp $ '\" .so man.macros .TH expr n 8.5 Tcl "Tcl Built-In Commands" @@ -17,7 +17,6 @@ expr \- Evaluate an expression .SH SYNOPSIS \fBexpr \fIarg \fR?\fIarg arg ...\fR? .BE - .SH DESCRIPTION .PP Concatenates \fIarg\fRs (adding separator spaces between them), @@ -210,11 +209,18 @@ not needed to determine the outcome. For example, in the command .CS \fBexpr {$v ? [a] : [b]}\fR .CE -only one of \fB[a]\fR or \fB[b]\fR will actually be evaluated, +only one of +.QW \fB[a]\fR +or +.QW \fB[b]\fR +will actually be evaluated, depending on the value of \fB$v\fR. Note, however, that this is only true if the entire expression is enclosed in braces; otherwise -the Tcl parser will evaluate both \fB[a]\fR and \fB[b]\fR before -invoking the \fBexpr\fR command. +the Tcl parser will evaluate both +.QW \fB[a]\fR +and +.QW \fB[b]\fR +before invoking the \fBexpr\fR command. .SS "MATH FUNCTIONS" .PP .VS 8.5 @@ -229,6 +235,11 @@ is the same in every way as the processing of: .CS \fBexpr {[tcl::mathfunc::sin [expr {$x+$y}]]}\fR .CE +which in turn is the same as the processing of: +.CS +\fBtcl::mathfunc::sin [expr {$x+$y}]\fR +.CE +.PP The executor will search for \fBtcl::mathfunc::sin\fR using the usual rules for resolving functions in namespaces. Either \fB::tcl::mathfunc::sin\fR or \fB[namespace @@ -382,16 +393,13 @@ Generate a random integer in the range 0..99 inclusive: .CS set randNum [\fBexpr\fR { int(100 * rand()) }] .CE - .SH "SEE ALSO" array(n), for(n), if(n), mathfunc(n), namespace(n), proc(n), string(n), Tcl(n), while(n) - .SH KEYWORDS arithmetic, boolean, compare, expression, fuzzy comparison - .SH COPYRIGHT +.ni Copyright (c) 1993 The Regents of the University of California. -.br Copyright (c) 1994-2000 Sun Microsystems Incorporated. -.br Copyright (c) 2005 by Kevin B. Kenny . All rights reserved. +.fi diff --git a/doc/mathfunc.n b/doc/mathfunc.n index 6fe9162..8a45821 100644 --- a/doc/mathfunc.n +++ b/doc/mathfunc.n @@ -6,7 +6,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: mathfunc.n,v 1.16 2007/10/29 11:28:50 dkf Exp $ +'\" RCS: @(#) $Id: mathfunc.n,v 1.17 2007/10/30 14:21:52 dkf Exp $ '\" .so man.macros .TH mathfunc n 8.5 Tcl "Tcl Mathematical Functions" @@ -108,112 +108,113 @@ of which work solely with floating-point numbers unless otherwise noted: .DE .PP .TP -\fBabs(\fIarg\fB)\fR +\fBabs \fIarg\fR Returns the absolute value of \fIarg\fR. \fIArg\fR may be either integer or floating-point, and the result is returned in the same form. .TP -\fBacos(\fIarg\fB)\fR +\fBacos \fIarg\fR Returns the arc cosine of \fIarg\fR, in the range [\fI0\fR,\fIpi\fR] radians. \fIArg\fR should be in the range [\fI\-1\fR,\fI1\fR]. .TP -\fBasin(\fIarg\fB)\fR +\fBasin \fIarg\fR Returns the arc sine of \fIarg\fR, in the range [\fI\-pi/2\fR,\fIpi/2\fR] radians. \fIArg\fR should be in the range [\fI\-1\fR,\fI1\fR]. .TP -\fBatan(\fIarg\fB)\fR +\fBatan \fIarg\fR Returns the arc tangent of \fIarg\fR, in the range [\fI\-pi/2\fR,\fIpi/2\fR] radians. .TP -\fBatan2(\fIy, x\fB)\fR +\fBatan2 \fIy x\fR Returns the arc tangent of \fIy\fR/\fIx\fR, in the range [\fI\-pi\fR,\fIpi\fR] radians. \fIx\fR and \fIy\fR cannot both be 0. If \fIx\fR is greater -than \fI0\fR, this is equivalent to \fBatan(\fIy/x\fB)\fR. +than \fI0\fR, this is equivalent to +.QW "\fBatan \fR[\fBexpr\fR {\fIy\fB/\fIx\fR}]\fR" . .TP -\fBbool(\fIarg\fB)\fR +\fBbool \fIarg\fR Accepts any numeric value, or any string acceptable to \fBstring is boolean\fR, and returns the corresponding boolean value \fB0\fR or \fB1\fR. Non-zero numbers are true. Other numbers are false. Non-numeric strings produce boolean value in agreement with \fBstring is true\fR and \fBstring is false\fR. .TP -\fBceil(\fIarg\fB)\fR +\fBceil \fIarg\fR Returns the smallest integral floating-point value (i.e. with a zero fractional part) not less than \fIarg\fR. The argument may be any numeric value. .TP -\fBcos(\fIarg\fB)\fR +\fBcos \fIarg\fR Returns the cosine of \fIarg\fR, measured in radians. .TP -\fBcosh(\fIarg\fB)\fR +\fBcosh \fIarg\fR Returns the hyperbolic cosine of \fIarg\fR. If the result would cause an overflow, an error is returned. .TP -\fBdouble(\fIarg\fB)\fR +\fBdouble \fIarg\fR The argument may be any numeric value, If \fIarg\fR is a floating-point value, returns \fIarg\fR, otherwise converts \fIarg\fR to floating-point and returns the converted value. May return \fBInf\fR or \fB\-Inf\fR when the argument is a numeric value that exceeds the floating-point range. .TP -\fBentier(\fIarg\fB)\fR +\fBentier \fIarg\fR .VS 8.5 The argument may be any numeric value. The integer part of \fIarg\fR is determined and returned. The integer range returned by this function -is unlimited, unlike functions \fBint()\fR and \fBwide()\fR which +is unlimited, unlike \fBint\fR and \fBwide\fR which truncate their range to fit in particular storage widths. .VE 8.5 .TP -\fBexp(\fIarg\fB)\fR +\fBexp \fIarg\fR Returns the exponential of \fIarg\fR, defined as \fIe\fR**\fIarg\fR. If the result would cause an overflow, an error is returned. .TP -\fBfloor(\fIarg\fB)\fR +\fBfloor \fIarg\fR Returns the largest integral floating-point value (i.e. with a zero fractional part) not greater than \fIarg\fR. The argument may be any numeric value. .TP -\fBfmod(\fIx, y\fB)\fR +\fBfmod \fIx y\fR Returns the floating-point remainder of the division of \fIx\fR by \fIy\fR. If \fIy\fR is 0, an error is returned. .TP -\fBhypot(\fIx, y\fB)\fR +\fBhypot \fIx y\fR Computes the length of the hypotenuse of a right-angled triangle -\fBsqrt(\fIx\fR*\fIx\fR+\fIy\fR*\fIy\fB)\fR. +.QW "\fBsqrt\fR [\fBexpr\fR {\fIx\fB*\fIx\fB+\fIy\fB*\fIy\fR}]". .TP -\fBint(\fIarg\fB)\fR +\fBint \fIarg\fR The argument may be any numeric value. The integer part of \fIarg\fR is determined, and then the low order bits of that integer value up to the machine word size are returned as an integer value. For reference, the number of bytes in the machine word are stored in \fBtcl_platform(wordSize)\fR. .TP -\fBisqrt(\fIarg\fB)\fR +\fBisqrt \fIarg\fR Computes the integer part of the square root of \fIarg\fR. \fIArg\fR must be a positive value, either an integer or a floating point number. Unlike \fBsqrt\fR, which is limited to the precision of a floating point number, \fIisqrt\fR will return a result of arbitrary precision. .TP -\fBlog(\fIarg\fB)\fR +\fBlog \fIarg\fR Returns the natural logarithm of \fIarg\fR. \fIArg\fR must be a positive value. .TP -\fBlog10(\fIarg\fB)\fR +\fBlog10 \fIarg\fR Returns the base 10 logarithm of \fIarg\fR. \fIArg\fR must be a positive value. .TP -\fBmax(\fIarg\fB, \fI...\fB)\fR +\fBmax \fIarg\fB \fI...\fR Accepts one or more numeric arguments. Returns the one argument with the greatest value. .TP -\fBmin(\fIarg\fB, \fI...\fB)\fR +\fBmin \fIarg\fB \fI...\fR Accepts one or more numeric arguments. Returns the one argument with the least value. .TP -\fBpow(\fIx, y\fB)\fR +\fBpow \fIx y\fR Computes the value of \fIx\fR raised to the power \fIy\fR. If \fIx\fR is negative, \fIy\fR must be an integer value. .TP -\fBrand()\fR +\fBrand\fR Returns a pseudo-random floating-point value in the range (\fI0\fR,\fI1\fR). The generator algorithm is a simple linear congruential generator that is not cryptographically secure. Each result from \fBrand\fR completely @@ -222,35 +223,35 @@ determines all future results from subsequent calls to \fBrand\fR, so one-time passwords. The seed of the generator is initialized from the internal clock of the machine or may be set with the \fBsrand\fR function. .TP -\fBround(\fIarg\fB)\fR +\fBround \fIarg\fR If \fIarg\fR is an integer value, returns \fIarg\fR, otherwise converts \fIarg\fR to integer by rounding and returns the converted value. .TP -\fBsin(\fIarg\fB)\fR +\fBsin \fIarg\fR Returns the sine of \fIarg\fR, measured in radians. .TP -\fBsinh(\fIarg\fB)\fR +\fBsinh \fIarg\fR Returns the hyperbolic sine of \fIarg\fR. If the result would cause an overflow, an error is returned. .TP -\fBsqrt(\fIarg\fB)\fR +\fBsqrt \fIarg\fR The argument may be any non-negative numeric value. Returns a floating-point value that is the square root of \fIarg\fR. May return \fBInf\fR when the argument is a numeric value that exceeds the square of the maximum value of the floating-point range. .TP -\fBsrand(\fIarg\fB)\fR +\fBsrand \fIarg\fR The \fIarg\fR, which must be an integer, is used to reset the seed for the random number generator of \fBrand\fR. Returns the first random -number (see \fBrand()\fR) from that seed. Each interpreter has its own seed. +number (see \fBrand\fR) from that seed. Each interpreter has its own seed. .TP -\fBtan(\fIarg\fB)\fR +\fBtan \fIarg\fR Returns the tangent of \fIarg\fR, measured in radians. .TP -\fBtanh(\fIarg\fB)\fR +\fBtanh \fIarg\fR Returns the hyperbolic tangent of \fIarg\fR. .TP -\fBwide(\fIarg\fB)\fR +\fBwide \fIarg\fR The argument may be any numeric value. The integer part of \fIarg\fR is determined, and then the low order 64 bits of that integer value are returned as an integer value. @@ -265,8 +266,8 @@ for new implementations. .SH "SEE ALSO" expr(n), namespace(n) .SH "COPYRIGHT" +.nf Copyright (c) 1993 The Regents of the University of California. -.br Copyright (c) 1994-2000 Sun Microsystems Incorporated. -.br Copyright (c) 2005, 2006 by Kevin B. Kenny . +.fi -- cgit v0.12