[go: up one dir, main page]

Menu

[267579]: / man / en_US / setai.tea  Maximize  Restore  History

Download this file

162 lines (93 with data), 3.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
# Dos9 Manual pages, The Dos9 project
# Copyright (C) 2012-2013 Romain Garbi (DarkBatcher)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{{SET command (/A)(integers)}}
Evaluate a mathematical expression and assign the result to a variable.
This manual is about the {/A} switch from the {set|SET} command, when
using integers. For floating point arithmetics, please check
{setaf|SET (/A)(Floats)}.
{{Synopsis}}
${SET [/a | /a[:]i] variable=expression}
Evaluate an expression and assign the result to a variable.
The assign operator {=} can be replaced in the synopsis by one of the
following operators:
- Arithmetic operators :
-- {+=} : Add result to {variable}.
-- {-=} : Substract result to {variable}.
-- {*=} : Multiply {variable} by the result.
-- {/=} : Divide {variable} by the result.
- Logical operators :
-- {&&=} : Logical and between {variable} and the result.
-- {\|\|=} : Logical or between {variable} and the result.
- Bitwise operators :
-- {&=} : Bitwise and between {variable} and the result.
-- {\|=} : Bitwise or between {variable} and the result.
-- {^=} : Bitwise xor between {variable} and the result.
-- {>>=} : Bitwise left shift of {variable} by result bits.
-- {<<=} : Bitwise right shift of {variable} by result bits.
{{Operators}}
A mathematical expression is made of operators and operands. Every
opperand is separated from other opperands by an operator.
Interger arithmetics operators are:
- Arithmetic operators :
-- {*} : product.
-- {/} : division.
-- {%} : Modulo.
-- {+} : Addition.
-- {-} : Subtraction.
-- {=} : Assignment.
- Bitwise operators:
-- {\|} : Bitwise or.
-- {^} : Bitwise xor.
-- {&} : Bitwise and.
-- {>>} : Right shift.
-- {<<} : Left shift.
- Logical operators:
-- {\|\|} : Logical or.
-- {&&} : Logical and.
Operators have the following precedence (from greatest to lowest):
- {unary operators}
- {=}
- {*}, {/}, {%}
- {+}, {-}
- {>>}, {<<}
- {&&}, {&}
- {^}
- {\|\|}, {\|}
To avoid precedence issue, use the parenthesis {(} and {)}.
{dos9|Dos9} also include unary operators. Unary operators should be to
the left of the opperand it affects. Unary operators provided by {Dos9}
are:
- {-} : Negation.
- {~} : Bitwise not.
- {!} : Logical not.
Unary operators have the highest precedence.
{{Bases}}
In {dos9|Dos9} mathematical expressions, numbers can be specified in
three different numeric bases: decimal, octal and hexadecimal. By
default, numbers are suposed to be decimal, unless it is prefixed
by one of the following prefix:
- {0x} : Hexadecimal number.
- {0} : Octal number.
{{Note}}
This command uses {libinteval}, a parser compiled with {YACC}.
{{Compatibility}}
Fully compatible with {cmd.exe}. {&&} and {\|\|} are Dos9 extensions.
Available since version {0.7.1.0}.
{{See also}}
{set|SET command}, {setaf|SET command (/A)(floats)},
{setlocal|SETLOCAL command}