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
41 Returns the absolute value of X:
49 class OOp_Abs
: public OUnaryOperator
52 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
56 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
66 class OOp_Sign
: public OUnaryOperator
69 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
74 Modulo (like the % operator in C). Returns the remainder of N divided by M:
76 > SELECT MOD(234, 10);
85 class OOp_Mod
: public OBinaryOperator
88 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
92 Returns the largest integer value not greater than X:
96 > SELECT FLOOR(-1.23);
100 class OOp_Floor
: public OUnaryOperator
103 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
107 Returns the smallest integer value not less than X:
109 > SELECT CEILING(1.23);
111 > SELECT CEILING(-1.23);
115 class OOp_Ceiling
: public OUnaryOperator
118 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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);
127 > SELECT ROUND(-1.58);
129 > SELECT ROUND(1.58);
131 > SELECT ROUND(1.298, 1);
133 > SELECT ROUND(1.298, 0);
135 > SELECT ROUND(23.298, -1);
138 class OOp_Round
: public ONthOperator
141 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
145 Returns the value of e (the base of natural logarithms) raised to the power of X:
152 class OOp_Exp
: public OUnaryOperator
155 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
159 Returns the natural logarithm of X:
167 class OOp_Ln
: public OUnaryOperator
170 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
175 If called with one parameter, this function returns the natural logarithm of X:
182 If called with two parameters, this function returns the logarithm of X for an arbitary base B:
184 > SELECT LOG(2,65536);
189 class OOp_Log
: public ONthOperator
192 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
196 Returns the base-10 logarithm of X:
202 > SELECT LOG10(-100);
205 class OOp_Log10
: public OUnaryOperator
208 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
212 Returns the value of X raised to the power of Y:
219 class OOp_Pow
: public OBinaryOperator
222 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
226 Returns the non-negative square root of X:
233 class OOp_Sqrt
: public OUnaryOperator
236 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
240 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()+0.000000000000000000;
245 -> 3.141592653589793116
248 class OOp_Pi
: public ONthOperator
251 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
255 Returns the cosine of X, where X is given in radians:
260 class OOp_Cos
: public OUnaryOperator
263 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
267 Returns the sine of X, where X is given in radians:
273 class OOp_Sin
: public OUnaryOperator
276 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
279 Returns the tangent of X, where X is given in radians:
281 > SELECT TAN(PI()+1);
284 class OOp_Tan
: public OUnaryOperator
287 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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:
295 > SELECT ACOS(1.0001);
300 class OOp_ACos
: public OUnaryOperator
303 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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:
311 > SELECT ASIN('foo');
314 class OOp_ASin
: public OUnaryOperator
317 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
321 Returns the arc tangent of X, that is, the value whose tangent is X:
328 class OOp_ATan
: public OUnaryOperator
331 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
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);
339 > SELECT ATAN2(PI(),0);
343 class OOp_ATan2
: public OBinaryOperator
346 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
350 Returns the argument X, converted from radians to degrees:
352 > SELECT DEGREES(PI());
355 class OOp_Degrees
: public OUnaryOperator
358 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
362 Returns the argument X, converted from degrees to radians:
364 > SELECT RADIANS(90);
368 class OOp_Radians
: public OUnaryOperator
371 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const;
376 #endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */