Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/bouyer-socketcan]: src/external/bsd/bc/dist 2109069



details:   https://anonhg.NetBSD.org/src/rev/5a31749b9bad
branches:  bouyer-socketcan
changeset: 820872:5a31749b9bad
user:      wiz <wiz%NetBSD.org@localhost>
date:      Mon Apr 17 14:01:20 2017 +0000

description:
2109069

diffstat:

 external/bsd/bc/dist/bc.1 |  1277 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1277 insertions(+), 0 deletions(-)

diffs (truncated from 1281 to 300 lines):

diff -r fad535065972 -r 5a31749b9bad external/bsd/bc/dist/bc.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/bc/dist/bc.1 Mon Apr 17 14:01:20 2017 +0000
@@ -0,0 +1,1277 @@
+.\" $NetBSD: bc.1,v 1.2.2.2 2017/04/17 14:01:20 wiz Exp $
+.\"
+.\" bc.1 - the bc manual
+.\"
+.\" Copyright (C) 1991-1994, 1997, 2000, 2003, 2012-2017 Free Software Foundation, Inc.
+.\" Copyright (C) 2004, 2017 Philip A. Nelson
+.\" Copyright (C) 2017 Thomas Klausner
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of Philip A. Nelson nor the name of the Free Software
+.\"    Foundation may not be used to endorse or promote products derived from
+.\"    this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+.\" THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\"
+.\"
+.Dd April 16, 2017
+.Dt BC 1
+.Os
+.Sh NAME
+.Nm bc
+.Nd arbitrary precision calculator language
+.Sh SYNOPSIS
+.Nm
+.Op Fl hilqsvw
+.Op long-options
+.Op Ar
+.Sh DESCRIPTION
+.Nm
+is a language that supports arbitrary precision numbers
+with interactive execution of statements.
+There are some similarities
+in the syntax to the C programming language.
+A standard math library is available by command line option.
+If requested, the math library is defined before processing any files.
+.Nm
+starts by processing code from all the files listed
+on the command line in the order listed.
+After all files have been processed,
+.Nm
+reads from the standard input.
+All code is executed as it is read.
+(If a file contains a command to halt the processor,
+.Nm
+will never read from the standard input.)
+.Pp
+This version of
+.Nm
+contains several extensions beyond traditional
+.Nm
+implementations and the POSIX draft standard.
+Command line options can cause these extensions to print a warning
+or to be rejected.
+This document describes the language accepted by this processor.
+Extensions will be identified as such.
+.Ss OPTIONS
+.Bl -tag -width "XXinteractiveXXXXXX"
+.It Fl h , Fl Fl help
+Print the usage and exit.
+.It Fl i , Fl Fl interactive
+Force interactive mode.
+.It Fl l , Fl Fl mathlib
+Define the standard math library.
+.It Fl q , Fl Fl quiet
+Quiet mode.
+.It Fl s , Fl Fl standard
+Process exactly the POSIX
+.Nm
+language.
+.It Fl v , Fl Fl version
+Print the version number and copyright and quit.
+.It Fl w , Fl Fl warn
+Give warnings for extensions to POSIX
+.Nm .
+.El
+.Ss NUMBERS
+The most basic element in
+.Nm
+is the number.
+Numbers are arbitrary precision numbers.
+This precision is both in the integer
+part and the fractional part.
+All numbers are represented internally
+in decimal and all computation is done in decimal.
+(This version of
+.Nm
+truncates results from divide and multiply operations.)
+There are two attributes of numbers, the length and the scale.
+The length is the
+total number of significant decimal digits in a number and the scale
+is the total number of decimal digits after the decimal point.
+For example:
+.Bd -literal
+ .000001 has a length of 6 and scale of 6.
+ 1935.000 has a length of 7 and a scale of 3.
+.Ed
+.Ss VARIABLES
+Numbers are stored in two types of variables, simple variables and
+arrays.
+Both simple variables and array variables are named.
+Names begin with a letter followed by any number of letters, digits and
+underscores.
+All letters must be lower case.
+(Full alpha-numeric names are an extension.
+In POSIX
+.Nm
+all names are a single lower case letter.)
+The type of variable is clear by the context
+because all array variable names will be followed by brackets ([]).
+.Pp
+There are four special variables,
+.Ic scale ,
+.Ic ibase ,
+.Ic obase ,
+and
+.Ic last .
+.Ic scale
+defines how some operations use digits after the decimal point.
+The default value of
+.Ic scale
+is 0.
+.Ic ibase
+and
+.Ic obase
+define the conversion base for input and output numbers.
+The default for both input and output is base 10.
+.Ic last
+(an extension) is a variable that has the value of the last
+printed number.
+These will be discussed in further detail where appropriate.
+All of these variables may have values assigned to them
+as well as used in expressions.
+.Ss COMMENTS
+Comments in
+.Nm
+start with the characters
+.Dq Ic /*
+and end with the characters
+.Dq Ic */ .
+Comments may start anywhere and appear as a single space in the input.
+(This causes comments to delimit other input items.
+For example, a comment can not be found in the middle of
+a variable name.)
+Comments include any newlines (end of line) between
+the start and the end of the comment.
+.Pp
+To support the use of scripts for
+.Nm ,
+a single line comment has been added as an extension.
+A single line comment starts at a
+.Dq Ic #
+character and continues to the next end of the line.
+The end of line
+character is not part of the comment and is processed normally.
+.Ss EXPRESSIONS
+The numbers are manipulated by expressions and statements.
+Since the language was designed to be interactive, statements and expressions
+are executed as soon as possible.
+There is no
+.Dq main
+program.
+Instead, code is executed as it is encountered.
+(Functions, discussed in
+detail later, are defined when encountered.)
+.Pp
+A simple expression is just a constant.
+.Nm
+converts constants
+into internal decimal numbers using the current input base, specified
+by the variable
+.Ic ibase .
+(There is an exception in functions.)
+The legal values of
+.Ic ibase
+are 2 through 36.
+(Base values greater than 16 are an extension.)
+Assigning a value outside this range to
+.Ic ibase
+will result in a value of 2 or 36.
+Input numbers may contain the characters 0-9 and A-Z.
+(Note: They must be capitals.
+Lower case letters are variable names.)
+Single digit numbers always
+have the value of the digit regardless of the value of
+.Ic ibase .
+(i.e. A = 10.)
+For multi-digit numbers,
+.Nm
+changes all input digits greater or equal to ibase to the value of
+.Ic ibase - 1 .
+This makes the number
+.Dq ZZZ
+always be the largest 3 digit number of the input base.
+.Pp
+Full expressions are similar to many other high level languages.
+Since there is only one kind of number, there are no rules for mixing
+types.
+Instead, there are rules on the scale of expressions.
+Every expression has a scale.
+This is derived from the scale of original
+numbers, the operation performed and in many cases, the value of the
+variable
+.Ic scale .
+Legal values of the variable
+.Ic scale
+are 0 to the maximum number representable by a C integer.
+.Pp
+In the following descriptions of legal expressions,
+.Dq expr
+refers to a complete expression and
+.Dq var
+refers to a simple or an array variable.
+A simple variable is just a
+.Ic name
+and an array variable is specified as
+.Ic name[expr] .
+Unless specifically mentioned the scale of the result is the maximum scale of the
+expressions involved.
+.Bl -tag -width 15n
+.It Ic "- expr"
+The result is the negation of the expression.
+.It Ic "++ var"
+The variable is incremented by one and the new value is the result of
+the expression.
+.It Ic "-- var"
+The variable is decremented by one and the new value is the result of the
+expression.
+.It Ic "var ++"
+The result of the expression is the value of
+the variable and then the variable is incremented by one.
+.It Ic "var --"
+The result of the expression is the value of the variable and then
+the variable is decremented by one.
+.It Ic "expr + expr"
+The result of the expression is the sum of the two expressions.
+.It Ic "expr - expr"
+The result of the expression is the difference of the two expressions.
+.It Ic "expr * expr"
+The result of the expression is the product of the two expressions.
+.It Ic "expr / expr"
+The result of the expression is the quotient of the two expressions.
+The scale of the result is the value of the variable \fBscale\fR.
+.It Ic "expr % expr"
+The result of the expression is the remainder and it is computed in the
+following way:
+To compute a%b, first a/b is computed to
+.Ic scale
+digits.
+That result is used to compute a-(a/b)*b to the scale of the
+maximum of
+.Ic scale +
+scale(b) and scale(a).
+If
+.Ic scale
+is set to zero and both expressions are integers this expression is the
+integer remainder function.
+.It Ic "expr ^ expr"
+The result of the expression is the value of the first raised to the
+second.
+The second expression must be an integer.
+(If the second expression is not an integer, a warning is generated and the
+expression is truncated to get an integer value.)
+The scale of the result is
+.Ic scale
+if the exponent is negative.
+If the exponent is positive, the scale of the result is the minimum of
+the scale of the first expression times the value of the exponent and
+the maximum of
+.Ic scale
+and the scale of the first expression.
+(e.g. scale(a^b) = min(scale(a)*b, max(
+.Ic scale ,
+scale(a))).)
+It should be noted
+that expr^0 will always return the value of 1.
+.It Ic "( expr )"
+This alters the standard precedence to force the evaluation of the



Home | Main Index | Thread Index | Old Index