bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / inc / file / FNumericFunctions.hxx
bloba8a5267b058d184112d89c59baecad0ccbfd9d24
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FNUMERICFUNCTIONS_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FNUMERICFUNCTIONS_HXX
23 #include "file/fcode.hxx"
24 #include "file/filedllapi.hxx"
26 namespace connectivity
28 namespace file
30 /** ABS(X)
31 Returns the absolute value of X:
33 > SELECT ABS(2);
34 -> 2
35 > SELECT ABS(-32);
36 -> 32
39 class OOp_Abs : public OUnaryOperator
41 protected:
42 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
45 /** SIGN(X)
46 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
48 > SELECT SIGN(-32);
49 -> -1
50 > SELECT SIGN(0);
51 -> 0
52 > SELECT SIGN(234);
53 -> 1
56 class OOp_Sign : public OUnaryOperator
58 protected:
59 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
62 /** MOD(N,M)
64 Modulo (like the % operator in C). Returns the remainder of N divided by M:
66 > SELECT MOD(234, 10);
67 -> 4
68 > SELECT 253 % 7;
69 -> 1
70 > SELECT MOD(29,9);
71 -> 2
72 > SELECT 29 MOD 9;
73 -> 2
75 class OOp_Mod : public OBinaryOperator
77 protected:
78 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
81 /** FLOOR(X)
82 Returns the largest integer value not greater than X:
84 > SELECT FLOOR(1.23);
85 -> 1
86 > SELECT FLOOR(-1.23);
87 -> -2
90 class OOp_Floor : public OUnaryOperator
92 protected:
93 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
96 /** CEILING(X)
97 Returns the smallest integer value not less than X:
99 > SELECT CEILING(1.23);
100 -> 2
101 > SELECT CEILING(-1.23);
102 -> -1
105 class OOp_Ceiling : public OUnaryOperator
107 protected:
108 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
111 /** ROUND(X)
112 ROUND(X,D)
113 Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals.
115 > SELECT ROUND(-1.23);
116 -> -1
117 > SELECT ROUND(-1.58);
118 -> -2
119 > SELECT ROUND(1.58);
120 -> 2
121 > SELECT ROUND(1.298, 1);
122 -> 1.3
123 > SELECT ROUND(1.298, 0);
124 -> 1
125 > SELECT ROUND(23.298, -1);
126 -> 20
128 class OOp_Round : public ONthOperator
130 protected:
131 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
134 /** EXP(X)
135 Returns the value of e (the base of natural logarithms) raised to the power of X:
137 > SELECT EXP(2);
138 -> 7.389056
139 > SELECT EXP(-2);
140 -> 0.135335
142 class OOp_Exp : public OUnaryOperator
144 protected:
145 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
148 /** LN(X)
149 Returns the natural logarithm of X:
151 > SELECT LN(2);
152 -> 0.693147
153 > SELECT LN(-2);
154 -> NULL
157 class OOp_Ln : public OUnaryOperator
159 protected:
160 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
163 /** LOG(X)
164 LOG(B,X)
165 If called with one parameter, this function returns the natural logarithm of X:
167 > SELECT LOG(2);
168 -> 0.693147
169 > SELECT LOG(-2);
170 -> NULL
172 If called with two parameters, this function returns the logarithm of X for an arbitrary base B:
174 > SELECT LOG(2,65536);
175 -> 16.000000
176 > SELECT LOG(1,100);
177 -> NULL
179 class OOp_Log : public ONthOperator
181 protected:
182 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
185 /** LOG10(X)
186 Returns the base-10 logarithm of X:
188 > SELECT LOG10(2);
189 -> 0.301030
190 > SELECT LOG10(100);
191 -> 2.000000
192 > SELECT LOG10(-100);
193 -> NULL
195 class OOp_Log10 : public OUnaryOperator
197 protected:
198 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
201 /** POWER(X,Y)
202 Returns the value of X raised to the power of Y:
204 > SELECT POW(2,2);
205 -> 4.000000
206 > SELECT POW(2,-2);
207 -> 0.250000
209 class OOp_Pow : public OBinaryOperator
211 protected:
212 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
215 /** SQRT(X)
216 Returns the non-negative square root of X:
218 > SELECT SQRT(4);
219 -> 2.000000
220 > SELECT SQRT(20);
221 -> 4.472136
223 class OOp_Sqrt : public OUnaryOperator
225 protected:
226 virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
229 /** PI()
230 Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
232 > SELECT PI();
233 -> 3.141593
234 > SELECT PI()+0.000000000000000000;
235 -> 3.141592653589793238
238 class OOp_Pi : public ONthOperator
240 protected:
241 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
244 /** COS(X)
245 Returns the cosine of X, where X is given in radians:
247 > SELECT COS(PI());
248 -> -1.000000
250 class OOp_Cos : public OUnaryOperator
252 protected:
253 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
256 /** SIN(X)
257 Returns the sine of X, where X is given in radians:
259 > SELECT SIN(PI());
260 -> 0.000000
263 class OOp_Sin : public OUnaryOperator
265 protected:
266 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
268 /** TAN(X)
269 Returns the tangent of X, where X is given in radians:
271 > SELECT TAN(PI()+1);
272 -> 1.557408
274 class OOp_Tan : public OUnaryOperator
276 protected:
277 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
280 /** ACOS(X)
281 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:
283 > SELECT ACOS(1);
284 -> 0.000000
285 > SELECT ACOS(1.0001);
286 -> NULL
287 > SELECT ACOS(0);
288 -> 1.570796
290 class OOp_ACos : public OUnaryOperator
292 protected:
293 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
296 /** ASIN(X)
297 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:
299 > SELECT ASIN(0.2);
300 -> 0.201358
301 > SELECT ASIN('foo');
302 -> 0.000000
304 class OOp_ASin : public OUnaryOperator
306 protected:
307 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
310 /** ATAN(X)
311 Returns the arc tangent of X, that is, the value whose tangent is X:
313 > SELECT ATAN(2);
314 -> 1.107149
315 > SELECT ATAN(-2);
316 -> -1.107149
318 class OOp_ATan : public OUnaryOperator
320 protected:
321 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
324 /** ATAN2(Y,X)
325 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:
327 > SELECT ATAN2(-2,2);
328 -> -0.785398
329 > SELECT ATAN2(PI(),0);
330 -> 1.570796
333 class OOp_ATan2 : public OBinaryOperator
335 protected:
336 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
339 /** DEGREES(X)
340 Returns the argument X, converted from radians to degrees:
342 > SELECT DEGREES(PI());
343 -> 180.000000
345 class OOp_Degrees : public OUnaryOperator
347 protected:
348 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
351 /** RADIANS(X)
352 Returns the argument X, converted from degrees to radians:
354 > SELECT RADIANS(90);
355 -> 1.570796
358 class OOp_Radians : public OUnaryOperator
360 protected:
361 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const SAL_OVERRIDE;
366 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FNUMERICFUNCTIONS_HXX
368 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */