Bump for 3.6-28
[LibreOffice.git] / connectivity / source / inc / file / FNumericFunctions.hxx
blobf98cdb7a26426f9d5f81e2dda3c86b1bc7258998
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
30 #define _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
32 #include "file/fcode.hxx"
33 #include "file/filedllapi.hxx"
35 namespace connectivity
37 class OSQLParseNode;
38 namespace file
40 /** ABS(X)
41 Returns the absolute value of X:
43 > SELECT ABS(2);
44 -> 2
45 > SELECT ABS(-32);
46 -> 32
49 class OOp_Abs : public OUnaryOperator
51 protected:
52 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
55 /** SIGN(X)
56 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
58 > SELECT SIGN(-32);
59 -> -1
60 > SELECT SIGN(0);
61 -> 0
62 > SELECT SIGN(234);
63 -> 1
66 class OOp_Sign : public OUnaryOperator
68 protected:
69 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
72 /** MOD(N,M)
74 Modulo (like the % operator in C). Returns the remainder of N divided by M:
76 > SELECT MOD(234, 10);
77 -> 4
78 > SELECT 253 % 7;
79 -> 1
80 > SELECT MOD(29,9);
81 -> 2
82 > SELECT 29 MOD 9;
83 -> 2
85 class OOp_Mod : public OBinaryOperator
87 protected:
88 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
91 /** FLOOR(X)
92 Returns the largest integer value not greater than X:
94 > SELECT FLOOR(1.23);
95 -> 1
96 > SELECT FLOOR(-1.23);
97 -> -2
100 class OOp_Floor : public OUnaryOperator
102 protected:
103 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
106 /** CEILING(X)
107 Returns the smallest integer value not less than X:
109 > SELECT CEILING(1.23);
110 -> 2
111 > SELECT CEILING(-1.23);
112 -> -1
115 class OOp_Ceiling : public OUnaryOperator
117 protected:
118 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
121 /** ROUND(X)
122 ROUND(X,D)
123 Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals.
125 > SELECT ROUND(-1.23);
126 -> -1
127 > SELECT ROUND(-1.58);
128 -> -2
129 > SELECT ROUND(1.58);
130 -> 2
131 > SELECT ROUND(1.298, 1);
132 -> 1.3
133 > SELECT ROUND(1.298, 0);
134 -> 1
135 > SELECT ROUND(23.298, -1);
136 -> 20
138 class OOp_Round : public ONthOperator
140 protected:
141 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
144 /** EXP(X)
145 Returns the value of e (the base of natural logarithms) raised to the power of X:
147 > SELECT EXP(2);
148 -> 7.389056
149 > SELECT EXP(-2);
150 -> 0.135335
152 class OOp_Exp : public OUnaryOperator
154 protected:
155 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
158 /** LN(X)
159 Returns the natural logarithm of X:
161 > SELECT LN(2);
162 -> 0.693147
163 > SELECT LN(-2);
164 -> NULL
167 class OOp_Ln : public OUnaryOperator
169 protected:
170 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
173 /** LOG(X)
174 LOG(B,X)
175 If called with one parameter, this function returns the natural logarithm of X:
177 > SELECT LOG(2);
178 -> 0.693147
179 > SELECT LOG(-2);
180 -> NULL
182 If called with two parameters, this function returns the logarithm of X for an arbitary base B:
184 > SELECT LOG(2,65536);
185 -> 16.000000
186 > SELECT LOG(1,100);
187 -> NULL
189 class OOp_Log : public ONthOperator
191 protected:
192 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
195 /** LOG10(X)
196 Returns the base-10 logarithm of X:
198 > SELECT LOG10(2);
199 -> 0.301030
200 > SELECT LOG10(100);
201 -> 2.000000
202 > SELECT LOG10(-100);
203 -> NULL
205 class OOp_Log10 : public OUnaryOperator
207 protected:
208 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
211 /** POWER(X,Y)
212 Returns the value of X raised to the power of Y:
214 > SELECT POW(2,2);
215 -> 4.000000
216 > SELECT POW(2,-2);
217 -> 0.250000
219 class OOp_Pow : public OBinaryOperator
221 protected:
222 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
225 /** SQRT(X)
226 Returns the non-negative square root of X:
228 > SELECT SQRT(4);
229 -> 2.000000
230 > SELECT SQRT(20);
231 -> 4.472136
233 class OOp_Sqrt : public OUnaryOperator
235 protected:
236 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
239 /** PI()
240 Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
242 > SELECT PI();
243 -> 3.141593
244 > SELECT PI()+0.000000000000000000;
245 -> 3.141592653589793116
248 class OOp_Pi : public ONthOperator
250 protected:
251 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
254 /** COS(X)
255 Returns the cosine of X, where X is given in radians:
257 > SELECT COS(PI());
258 -> -1.000000
260 class OOp_Cos : public OUnaryOperator
262 protected:
263 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
266 /** SIN(X)
267 Returns the sine of X, where X is given in radians:
269 > SELECT SIN(PI());
270 -> 0.000000
273 class OOp_Sin : public OUnaryOperator
275 protected:
276 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
278 /** TAN(X)
279 Returns the tangent of X, where X is given in radians:
281 > SELECT TAN(PI()+1);
282 -> 1.557408
284 class OOp_Tan : public OUnaryOperator
286 protected:
287 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
290 /** ACOS(X)
291 Returns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1:
293 > SELECT ACOS(1);
294 -> 0.000000
295 > SELECT ACOS(1.0001);
296 -> NULL
297 > SELECT ACOS(0);
298 -> 1.570796
300 class OOp_ACos : public OUnaryOperator
302 protected:
303 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
306 /** ASIN(X)
307 Returns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1:
309 > SELECT ASIN(0.2);
310 -> 0.201358
311 > SELECT ASIN('foo');
312 -> 0.000000
314 class OOp_ASin : public OUnaryOperator
316 protected:
317 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
320 /** ATAN(X)
321 Returns the arc tangent of X, that is, the value whose tangent is X:
323 > SELECT ATAN(2);
324 -> 1.107149
325 > SELECT ATAN(-2);
326 -> -1.107149
328 class OOp_ATan : public OUnaryOperator
330 protected:
331 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
334 /** ATAN2(Y,X)
335 Returns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result:
337 > SELECT ATAN2(-2,2);
338 -> -0.785398
339 > SELECT ATAN2(PI(),0);
340 -> 1.570796
343 class OOp_ATan2 : public OBinaryOperator
345 protected:
346 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
349 /** DEGREES(X)
350 Returns the argument X, converted from radians to degrees:
352 > SELECT DEGREES(PI());
353 -> 180.000000
355 class OOp_Degrees : public OUnaryOperator
357 protected:
358 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
361 /** RADIANS(X)
362 Returns the argument X, converted from degrees to radians:
364 > SELECT RADIANS(90);
365 -> 1.570796
368 class OOp_Radians : public OUnaryOperator
370 protected:
371 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
376 #endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */