update dev300-m58
[ooovba.git] / connectivity / source / inc / file / FNumericFunctions.hxx
blob6ba79cc279677decd1ec14b8b373b4c94ba43227
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FNumericFunctions.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
32 #define _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
34 #include "file/fcode.hxx"
35 #include "file/filedllapi.hxx"
37 namespace connectivity
39 class OSQLParseNode;
40 namespace file
42 /** ABS(X)
43 Returns the absolute value of X:
45 > SELECT ABS(2);
46 -> 2
47 > SELECT ABS(-32);
48 -> 32
51 class OOp_Abs : public OUnaryOperator
53 protected:
54 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
57 /** SIGN(X)
58 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
60 > SELECT SIGN(-32);
61 -> -1
62 > SELECT SIGN(0);
63 -> 0
64 > SELECT SIGN(234);
65 -> 1
68 class OOp_Sign : public OUnaryOperator
70 protected:
71 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
74 /** MOD(N,M)
76 Modulo (like the % operator in C). Returns the remainder of N divided by M:
78 > SELECT MOD(234, 10);
79 -> 4
80 > SELECT 253 % 7;
81 -> 1
82 > SELECT MOD(29,9);
83 -> 2
84 > SELECT 29 MOD 9;
85 -> 2
87 class OOp_Mod : public OBinaryOperator
89 protected:
90 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
93 /** FLOOR(X)
94 Returns the largest integer value not greater than X:
96 > SELECT FLOOR(1.23);
97 -> 1
98 > SELECT FLOOR(-1.23);
99 -> -2
102 class OOp_Floor : public OUnaryOperator
104 protected:
105 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
108 /** CEILING(X)
109 Returns the smallest integer value not less than X:
111 > SELECT CEILING(1.23);
112 -> 2
113 > SELECT CEILING(-1.23);
114 -> -1
117 class OOp_Ceiling : public OUnaryOperator
119 protected:
120 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
123 /** ROUND(X)
124 ROUND(X,D)
125 Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals.
127 > SELECT ROUND(-1.23);
128 -> -1
129 > SELECT ROUND(-1.58);
130 -> -2
131 > SELECT ROUND(1.58);
132 -> 2
133 > SELECT ROUND(1.298, 1);
134 -> 1.3
135 > SELECT ROUND(1.298, 0);
136 -> 1
137 > SELECT ROUND(23.298, -1);
138 -> 20
140 class OOp_Round : public ONthOperator
142 protected:
143 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
146 /** EXP(X)
147 Returns the value of e (the base of natural logarithms) raised to the power of X:
149 > SELECT EXP(2);
150 -> 7.389056
151 > SELECT EXP(-2);
152 -> 0.135335
154 class OOp_Exp : public OUnaryOperator
156 protected:
157 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
160 /** LN(X)
161 Returns the natural logarithm of X:
163 > SELECT LN(2);
164 -> 0.693147
165 > SELECT LN(-2);
166 -> NULL
169 class OOp_Ln : public OUnaryOperator
171 protected:
172 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
175 /** LOG(X)
176 LOG(B,X)
177 If called with one parameter, this function returns the natural logarithm of X:
179 > SELECT LOG(2);
180 -> 0.693147
181 > SELECT LOG(-2);
182 -> NULL
184 If called with two parameters, this function returns the logarithm of X for an arbitary base B:
186 > SELECT LOG(2,65536);
187 -> 16.000000
188 > SELECT LOG(1,100);
189 -> NULL
191 class OOp_Log : public ONthOperator
193 protected:
194 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
197 /** LOG10(X)
198 Returns the base-10 logarithm of X:
200 > SELECT LOG10(2);
201 -> 0.301030
202 > SELECT LOG10(100);
203 -> 2.000000
204 > SELECT LOG10(-100);
205 -> NULL
207 class OOp_Log10 : public OUnaryOperator
209 protected:
210 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
213 /** POWER(X,Y)
214 Returns the value of X raised to the power of Y:
216 > SELECT POW(2,2);
217 -> 4.000000
218 > SELECT POW(2,-2);
219 -> 0.250000
221 class OOp_Pow : public OBinaryOperator
223 protected:
224 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
227 /** SQRT(X)
228 Returns the non-negative square root of X:
230 > SELECT SQRT(4);
231 -> 2.000000
232 > SELECT SQRT(20);
233 -> 4.472136
235 class OOp_Sqrt : public OUnaryOperator
237 protected:
238 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
241 /** PI()
242 Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
244 > SELECT PI();
245 -> 3.141593
246 > SELECT PI()+0.000000000000000000;
247 -> 3.141592653589793116
250 class OOp_Pi : public ONthOperator
252 protected:
253 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
256 /** COS(X)
257 Returns the cosine of X, where X is given in radians:
259 > SELECT COS(PI());
260 -> -1.000000
262 class OOp_Cos : public OUnaryOperator
264 protected:
265 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
268 /** SIN(X)
269 Returns the sine of X, where X is given in radians:
271 > SELECT SIN(PI());
272 -> 0.000000
275 class OOp_Sin : public OUnaryOperator
277 protected:
278 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
280 /** TAN(X)
281 Returns the tangent of X, where X is given in radians:
283 > SELECT TAN(PI()+1);
284 -> 1.557408
286 class OOp_Tan : public OUnaryOperator
288 protected:
289 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
292 /** ACOS(X)
293 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:
295 > SELECT ACOS(1);
296 -> 0.000000
297 > SELECT ACOS(1.0001);
298 -> NULL
299 > SELECT ACOS(0);
300 -> 1.570796
302 class OOp_ACos : public OUnaryOperator
304 protected:
305 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
308 /** ASIN(X)
309 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:
311 > SELECT ASIN(0.2);
312 -> 0.201358
313 > SELECT ASIN('foo');
314 -> 0.000000
316 class OOp_ASin : public OUnaryOperator
318 protected:
319 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
322 /** ATAN(X)
323 Returns the arc tangent of X, that is, the value whose tangent is X:
325 > SELECT ATAN(2);
326 -> 1.107149
327 > SELECT ATAN(-2);
328 -> -1.107149
330 class OOp_ATan : public OUnaryOperator
332 protected:
333 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
336 /** ATAN2(Y,X)
337 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:
339 > SELECT ATAN2(-2,2);
340 -> -0.785398
341 > SELECT ATAN2(PI(),0);
342 -> 1.570796
345 class OOp_ATan2 : public OBinaryOperator
347 protected:
348 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
351 /** DEGREES(X)
352 Returns the argument X, converted from radians to degrees:
354 > SELECT DEGREES(PI());
355 -> 180.000000
357 class OOp_Degrees : public OUnaryOperator
359 protected:
360 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
363 /** RADIANS(X)
364 Returns the argument X, converted from degrees to radians:
366 > SELECT RADIANS(90);
367 -> 1.570796
370 class OOp_Radians : public OUnaryOperator
372 protected:
373 virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
378 #endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_