mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Release calc version 2.12.1.8
This commit is contained in:
127
help/pound
Normal file
127
help/pound
Normal file
@@ -0,0 +1,127 @@
|
||||
NAME
|
||||
#
|
||||
|
||||
SYNOPSIS
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
# x
|
||||
x # y
|
||||
## comment
|
||||
|
||||
TYPES
|
||||
x, y integer or real
|
||||
|
||||
return integer (uniary operator case)
|
||||
integer or real (binary operator case)
|
||||
|
||||
DESCRIPTION
|
||||
The pound sign or sharp sign "#" has special meaning in calc.
|
||||
|
||||
As a uniary operator:
|
||||
|
||||
# value
|
||||
|
||||
returns the number of 1 bits, or pop-count of the absolute value of
|
||||
the numerator (abs(num(value))). Therefore when x is a non-negative
|
||||
integer , # x is the pop-count of x. And thus when x is a negative
|
||||
integer, # x returns the pop-count of abs(x). And in the general
|
||||
case when x is a real, # x returns the pop-count of abs(num(x)).
|
||||
|
||||
As a binary operator:
|
||||
|
||||
x # y
|
||||
|
||||
returns abs(x-y), the absolute value of the difference.
|
||||
|
||||
When two or more pound signs in a row start a comment:
|
||||
|
||||
## this is a comment
|
||||
### this is also a comment
|
||||
print "this will print"; ## but this will not because it is a comment
|
||||
|
||||
A pound sign followed by a bang also starts a comment:
|
||||
|
||||
#! strictly speaking, this is a comment
|
||||
print "this is correct but not recommended" #! acts like ##
|
||||
|
||||
On POSIX / Un*X / Linux / BSD conforming systems, when an executable
|
||||
starts with the two bytes # and !, the remainder of the 1st line
|
||||
(up to an operating system imposed limit) is taken to be the path
|
||||
to the shell (plus shell arguments) that is to be executed. The
|
||||
kernel appends the filename of the executable as a final argument
|
||||
to the shell.
|
||||
|
||||
For example, of an executable file contains:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
/* NOTE: The #! above must start in column 1 of the 1st line */
|
||||
/* The 1st line must end with -f */
|
||||
## Single # shell comments don't work, use two or more
|
||||
print "2+2 =", 2+2;
|
||||
|
||||
When the above file it is executed by the kernel, it will print:
|
||||
|
||||
2+2 = 4
|
||||
|
||||
Such files are known to calc as cscripts. See "help cscript"
|
||||
for examples.
|
||||
|
||||
It is suggested that the -q be added to the first line to
|
||||
disable the reading of the startup scripts. It is not mandatory.
|
||||
|
||||
The last argument of the first line must be -f without the filename
|
||||
because the kernel will supply the cscript filename as a final
|
||||
argument. The final -f also implies -s. See "help usage" for
|
||||
more information.
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; #3
|
||||
2
|
||||
; #3.5
|
||||
3
|
||||
; 4 # 5
|
||||
1
|
||||
; 5 # 4
|
||||
1
|
||||
|
||||
; pi() # exp(1)
|
||||
0.4233108251307480031
|
||||
; exp(1) # pi()
|
||||
0.4233108251307480031
|
||||
|
||||
; ## this is a comment
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
cscript, unexpected, usage
|
||||
|
||||
## Copyright (C) 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.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: pound,v 29.1 2007/02/06 23:48:15 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/pound,v $
|
||||
##
|
||||
## Under source code control: 2007/02/06 14:09
|
||||
## File existed as early as: 2007
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
Reference in New Issue
Block a user