summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/scalc/01/04060199.xhp
blob: 0fbf698e12da19eb5f39e988c97ca2e9726a2c35 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->
<helpdocument version="1.0">
<meta>
<topic id="textscalc0104060199xml" indexer="include" status="PUBLISH">
<title id="tit">Operators in $[officename] Calc</title>
<filename>/text/scalc/01/04060199.xhp</filename>
</topic>
</meta>
<body>
<bookmark branch="index" id="bm_id3156445">
<bookmark_value>operators; in spreadsheet formulas</bookmark_value>
<bookmark_value>formulas; operators</bookmark_value>
<bookmark_value>operators; formula functions</bookmark_value>
</bookmark><comment>mw added 7 new index entries</comment>
<h1 id="hd_id3156445">Operators in $[officename] Calc</h1>
<paragraph role="paragraph" id="par_id3155812">You can use the following operators in $[officename] Calc:</paragraph>
<bookmark branch="index" id="bm_id891687563561282">
<bookmark_value>arithmetical operators</bookmark_value>
<bookmark_value>division sign, see also operators</bookmark_value>
<bookmark_value>multiplication sign, see also operators</bookmark_value>
<bookmark_value>minus sign, see also operators</bookmark_value>
<bookmark_value>plus sign, see also operators</bookmark_value>
</bookmark>
<h2 id="hd_id3153066">Arithmetical Operators</h2>
<paragraph role="paragraph" id="par_id3148601">These operators return numerical results.</paragraph>
<table id="tbl_id3151240">
<tablerow>
<tablecell>
<paragraph role="tablehead" id="par_id3144768">Operator</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id3157982">Name</paragraph>
</tablecell>
<tablecell>
    <paragraph role="tablehead" id="par_id401599494815994">Example</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3149126">+</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150892">Addition</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3153247" localize="false">1+1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3159204">-</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3145362">Subtraction</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3153554" localize="false">2-1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3153808">-</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3151193">Negation</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3154712" localize="false">-5</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3149873">*</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3147504">Multiplication</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3149055" localize="false">2*2</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent" localize="false"  id="par_id3151341">/</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3159260">Division</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3153027" localize="false">9/3</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3156396">%</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150372">Percent</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3145632" localize="false">15%</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3149722">^</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3159127">Exponentiation</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3157873" localize="false">3^2</paragraph>
</tablecell>
</tablerow>
</table>

<note id="par_id881623862728559">Prefix "-" (negation) has a higher precedence than "^" (exponentiation). For example -3^2 equals 9, which is the square of a negative number.</note>

<bookmark branch="index" id="bm_id481687564343986">
<bookmark_value>operators;comparison</bookmark_value>
<bookmark_value>comparisons;operators in Calc</bookmark_value>
</bookmark>
<h2 id="hd_id3152981">Comparative operators</h2>
<paragraph role="paragraph" id="par_id3157902">These operators return either true or false.</paragraph>
<table id="tbl_id3148725">
<tablerow>
<tablecell>
<paragraph role="tablehead" id="par_id3149889">Operator</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id3150743">Name</paragraph>
</tablecell>
<tablecell>
    <paragraph role="tablehead" id="par_id201599495083374">Example</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" localize="false" id="par_id3148888">=</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3154845">Equal</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3154546" localize="false">A1=B1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent" localize="false" id="par_id3154807">&gt;</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3148580">Greater than</paragraph>
</tablecell>
<tablecell>
    <paragraph role="tablecontent" id="par_id3145138" localize="false">A1&gt;B1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent"  localize="false" id="par_id3149507">&lt;</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150145">Less than</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150901" localize="false">A1&lt;B1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3153078">&gt;=</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150866">Greater than or equal to</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3153111" localize="false">A1&gt;=B1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent" localize="false"  id="par_id3153004">&lt;=</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150335">Less than or equal to</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3148760" localize="false">A1&lt;=B1</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3157994">&lt;&gt;</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150019">Inequality</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3149878" localize="false">A1&lt;&gt;B1</paragraph>
</tablecell>
</tablerow>
</table>
<bookmark branch="index" id="bm_id3157975">
<bookmark_value>text operators</bookmark_value>
<bookmark_value>text concatenation</bookmark_value>
</bookmark>
<h2 id="hd_id3145241">Text operators</h2>
<paragraph role="paragraph" id="par_id3155438">The operator combines separate texts into one text.</paragraph>
<table id="tbl_id3156061">
<tablerow>
<tablecell>
<paragraph role="tablehead" id="par_id3150566">Operator</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id3153048">Name</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id201599494708332">Example</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
    <paragraph role="tablecontent"  localize="false" id="par_id3148769">&amp;</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3157975">text concatenation</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3157993">"Sun" &amp; "day" is "Sunday"</paragraph>
</tablecell>
</tablerow>
</table>
<bookmark branch="index" id="bm_id291687563892759">
<bookmark_value>reference operators</bookmark_value>
<bookmark_value>intersection reference operator</bookmark_value>
<bookmark_value>union reference operator</bookmark_value>
<bookmark_value>range operator</bookmark_value>
</bookmark>
<section id="referenceoperators">
<h2 id="hd_id3153550">Reference operators</h2>
<paragraph role="paragraph" id="par_id3149024">These operators return a cell range of zero, one or more cells.</paragraph>
<paragraph role="paragraph" id="par_id2324900">Range has the highest precedence, then intersection, and then finally union.</paragraph>
<table id="tbl_id3154633">
<tablerow>
<tablecell>
<paragraph role="tablehead" id="par_id3158416">Operator</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id3152822">Name</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id521599494740206">Example</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" localize="false" id="par_id3156257">:</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3153924">Range</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3148432">A1:C108, A:D or 3:13</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" localize="false" id="par_id3152592">!</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3150606">Intersection</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3083445">SUM(A1:B6!B5:C12)</paragraph>
<paragraph role="tablecontent" id="par_id3150385">Calculates the sum of all cells in the intersection; in this example, the result yields the sum of cells B5 and B6.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" localize="false" id="par_id4003723">~</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id838953">Concatenation or union</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id2511978">Takes two references and returns a reference list, which is a concatenation of the left reference followed by the right reference. Double entries are referenced twice.</paragraph>
<paragraph role="paragraph" id="par_id961672071835372"><input>=COUNT(A1:B2~B2:C3)</input> counts values of A1:B2 and B2:C3. Note that the cell B2 is counted twice.</paragraph>
<paragraph role="paragraph" id="par_id401672243346224"><input>=INDEX(A1:B2~C1:D2;2;1;2)</input> selects cell C2, that is, the first cell of the second row, first column, of the second range (C1:D2) of the range list.</paragraph>
</tablecell>
</tablerow>
</table>
<note id="par_id181890">A reference list is not allowed inside an array expression.</note>
</section>
<bookmark xml-lang="en-US" branch="index" id="bm_id311687563684141">
    <bookmark_value>operators;precedence of</bookmark_value>
</bookmark>
<h2 id="hd_id981687562294437">Operator precedence</h2>
<paragraph role="paragraph" id="par_id271687562351999">Associativity and precedence of operators, from highest to lowest precedence.</paragraph>
<table id="tbl_precedence">
	<tablerow>
        <tablecell><paragraph role="tablehead" id="par_id461687561515440">Associativity</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablehead" id="par_id801687561518810">Operator(s)</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablehead" id="par_id521687561523649">Comments</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id611687561527049">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id561687561531281">:</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id651687561534345">Range.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id961687561539434">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id301687561544010">!</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id721687561546778">Reference intersection (A1:C4!B1:B5 is B1:B4).</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id741687561555251">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id901687561558641">~</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id121687561561898">Reference union.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id731687561708790">right</paragraph></tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id61687561711845">+,-</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id721687561715845">Prefix unary operators. For example, -5 or -A1. Note that these have a different precedence than add and subtract.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id171687561719559">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id561687561722949">%</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id791687561727359">Postfix unary operator % (divide by 100). Note that this is legal with expressions, for example, B1%.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id681687561735190">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id781687561738654">^</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id321687561741773">Power (2^3 is 8).</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id321687561745015">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id121687561747982">*,/</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id431687561758704">Multiply, divide.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id931687561762278">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id241687561766047">+,-</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id731687561770325">Binary operations add, subtract. Note that unary (prefix) + and - have a different precedence.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id541687561818607">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id421687561821896">&amp;</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id391687561825288">Binary operation string concatenation. Note that "&amp;" shall be escaped when included in an XML document.</paragraph>
		</tablecell>
	</tablerow>
	<tablerow>
        <tablecell><paragraph role="tablecontent" id="par_id921687561831376">left</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" localize="false" id="par_id41687561835121">=, &lt;&gt;, &lt;, &lt;=,<br/>&gt;, &gt;=</paragraph>
		</tablecell>
        <tablecell><paragraph role="tablecontent" id="par_id631687561838545">Comparison operators equal to, not equal to, less than, less than or equal to, greater than, greater than or equal to.</paragraph>
		</tablecell>
	</tablerow>
</table>
<note id="par_id241687561247336">Prefix "-" has a higher precedence than "^", "^" is left-associative, and reference intersection has a higher precedence than reference union.</note>
<note id="par_id941687561277896">Prefix "+" and "-" are defined to be right-associative. However, note that typical applications which implement at most the operators defined in this specification (as specified) may implement them as left-associative, because the calculated results will be identical.</note>
<note id="par_id411687561295059">Precedence can be overridden by using parentheses, so "=2+3*4" computes to 14 but "=(2+3)*4" computes 20.</note>
<section id="relatedtopics">
    <paragraph role="paragraph" id="par_id661687565493405"><link href="https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#Operators">OpenDocument v1.3 part 4, Formula Operators</link></paragraph>
</section>
</body>
</helpdocument>