mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.2
This commit is contained in:
@@ -38,34 +38,50 @@ Unexpected
|
||||
|
||||
|
||||
^ is not xor
|
||||
============
|
||||
|
||||
In C, ^ is the xor operator. Like the '**', '^' is the
|
||||
exponentiation operator. The expression:
|
||||
|
||||
a^b
|
||||
|
||||
yields "a to the b power", NOT "a xor b".
|
||||
|
||||
Note that 'b' must be an integer. Also if 'a' == 0, 'b'
|
||||
must be >= 0 as well.
|
||||
|
||||
To raise to a non-integer power, use the power() builtin function.
|
||||
|
||||
|
||||
** is exponentiation
|
||||
====================
|
||||
|
||||
As was suggested in the '^ is not xor' section, the expression:
|
||||
In C, ^ is the xor operator. The expression:
|
||||
|
||||
a**b
|
||||
a ^ b
|
||||
|
||||
yields "a to the b power", NOT "a xor b".
|
||||
|
||||
Note that 'b' must be an integer. Also if 'a' == 0, 'b'
|
||||
must be >= 0 as well.
|
||||
Unlike in C, calc evaluates the expression:
|
||||
|
||||
To raise to a non-integer power, use the power() builtin function.
|
||||
a ** b
|
||||
|
||||
also yields "a to the b power".
|
||||
|
||||
Here "a" and "b" can be a real value or a complex value:
|
||||
|
||||
2^3 3i^4
|
||||
2.5 ^ 3.5 0.5i ^ 0.25
|
||||
2.5 ^ 2.718i 3.13145i ^ 0.30103i
|
||||
|
||||
In addition, "a" can be matrix. In this case "b" must be an integer:
|
||||
|
||||
mat a[2,2] = {1,2,3,4};
|
||||
a^3
|
||||
|
||||
Note that 'a' == 0 and 'b' is real, then is must be >= 0 as well.
|
||||
Also 0^0 and 0**0 return the value 1.
|
||||
|
||||
Be careful about the precedence of operators. Note that:
|
||||
|
||||
-1 ^ 0.5 == -1
|
||||
|
||||
whereas:
|
||||
|
||||
(-1) ^ 0.5 == 1i
|
||||
|
||||
because the above expresssion in parsed as:
|
||||
|
||||
-(1 ^ 0.5) == -1
|
||||
|
||||
whereas:
|
||||
|
||||
(-1) ^ 0.5 == 1i
|
||||
|
||||
|
||||
op= operators associate left to right
|
||||
@@ -333,10 +349,10 @@ Unexpected
|
||||
## 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.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: unexpected,v 29.4 2007/02/07 00:30:33 chongo Exp $
|
||||
## @(#) $Revision: 30.2 $
|
||||
## @(#) $Id: unexpected,v 30.2 2007/07/11 23:00:39 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/unexpected,v $
|
||||
##
|
||||
## Under source code control: 1997/03/21 13:15:18
|
||||
|
Reference in New Issue
Block a user