1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FNumericFunctions.hxx,v $
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
43 Returns the absolute value of X:
51 class OOp_Abs
: public OUnaryOperator
54 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
58 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
68 class OOp_Sign
: public OUnaryOperator
71 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
76 Modulo (like the % operator in C). Returns the remainder of N divided by M:
78 > SELECT MOD(234, 10);
87 class OOp_Mod
: public OBinaryOperator
90 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
94 Returns the largest integer value not greater than X:
98 > SELECT FLOOR(-1.23);
102 class OOp_Floor
: public OUnaryOperator
105 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
109 Returns the smallest integer value not less than X:
111 > SELECT CEILING(1.23);
113 > SELECT CEILING(-1.23);
117 class OOp_Ceiling
: public OUnaryOperator
120 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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);
129 > SELECT ROUND(-1.58);
131 > SELECT ROUND(1.58);
133 > SELECT ROUND(1.298, 1);
135 > SELECT ROUND(1.298, 0);
137 > SELECT ROUND(23.298, -1);
140 class OOp_Round
: public ONthOperator
143 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
147 Returns the value of e (the base of natural logarithms) raised to the power of X:
154 class OOp_Exp
: public OUnaryOperator
157 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
161 Returns the natural logarithm of X:
169 class OOp_Ln
: public OUnaryOperator
172 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
177 If called with one parameter, this function returns the natural logarithm of X:
184 If called with two parameters, this function returns the logarithm of X for an arbitary base B:
186 > SELECT LOG(2,65536);
191 class OOp_Log
: public ONthOperator
194 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
198 Returns the base-10 logarithm of X:
204 > SELECT LOG10(-100);
207 class OOp_Log10
: public OUnaryOperator
210 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
214 Returns the value of X raised to the power of Y:
221 class OOp_Pow
: public OBinaryOperator
224 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
228 Returns the non-negative square root of X:
235 class OOp_Sqrt
: public OUnaryOperator
238 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
242 Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
246 > SELECT PI()+0.000000000000000000;
247 -> 3.141592653589793116
250 class OOp_Pi
: public ONthOperator
253 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
257 Returns the cosine of X, where X is given in radians:
262 class OOp_Cos
: public OUnaryOperator
265 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
269 Returns the sine of X, where X is given in radians:
275 class OOp_Sin
: public OUnaryOperator
278 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
281 Returns the tangent of X, where X is given in radians:
283 > SELECT TAN(PI()+1);
286 class OOp_Tan
: public OUnaryOperator
289 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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:
297 > SELECT ACOS(1.0001);
302 class OOp_ACos
: public OUnaryOperator
305 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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:
313 > SELECT ASIN('foo');
316 class OOp_ASin
: public OUnaryOperator
319 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
323 Returns the arc tangent of X, that is, the value whose tangent is X:
330 class OOp_ATan
: public OUnaryOperator
333 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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);
341 > SELECT ATAN2(PI(),0);
345 class OOp_ATan2
: public OBinaryOperator
348 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
352 Returns the argument X, converted from radians to degrees:
354 > SELECT DEGREES(PI());
357 class OOp_Degrees
: public OUnaryOperator
360 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
364 Returns the argument X, converted from degrees to radians:
366 > SELECT RADIANS(90);
370 class OOp_Radians
: public OUnaryOperator
373 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
378 #endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_