1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
31 Returns the absolute value of X:
39 class OOp_Abs
: public OUnaryOperator
42 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
46 Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
56 class OOp_Sign
: public OUnaryOperator
59 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
64 Modulo (like the % operator in C). Returns the remainder of N divided by M:
66 > SELECT MOD(234, 10);
75 class OOp_Mod
: public OBinaryOperator
78 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
82 Returns the largest integer value not greater than X:
86 > SELECT FLOOR(-1.23);
90 class OOp_Floor
: public OUnaryOperator
93 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
97 Returns the smallest integer value not less than X:
99 > SELECT CEILING(1.23);
101 > SELECT CEILING(-1.23);
105 class OOp_Ceiling
: public OUnaryOperator
108 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
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);
117 > SELECT ROUND(-1.58);
119 > SELECT ROUND(1.58);
121 > SELECT ROUND(1.298, 1);
123 > SELECT ROUND(1.298, 0);
125 > SELECT ROUND(23.298, -1);
128 class OOp_Round
: public ONthOperator
131 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
135 Returns the value of e (the base of natural logarithms) raised to the power of X:
142 class OOp_Exp
: public OUnaryOperator
145 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
149 Returns the natural logarithm of X:
157 class OOp_Ln
: public OUnaryOperator
160 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
165 If called with one parameter, this function returns the natural logarithm of X:
172 If called with two parameters, this function returns the logarithm of X for an arbitrary base B:
174 > SELECT LOG(2,65536);
179 class OOp_Log
: public ONthOperator
182 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
186 Returns the base-10 logarithm of X:
192 > SELECT LOG10(-100);
195 class OOp_Log10
: public OUnaryOperator
198 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
202 Returns the value of X raised to the power of Y:
209 class OOp_Pow
: public OBinaryOperator
212 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
216 Returns the non-negative square root of X:
223 class OOp_Sqrt
: public OUnaryOperator
226 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
230 Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
234 > SELECT PI()+0.000000000000000000;
235 -> 3.141592653589793238
238 class OOp_Pi
: public ONthOperator
241 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
245 Returns the cosine of X, where X is given in radians:
250 class OOp_Cos
: public OUnaryOperator
253 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
257 Returns the sine of X, where X is given in radians:
263 class OOp_Sin
: public OUnaryOperator
266 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
269 Returns the tangent of X, where X is given in radians:
271 > SELECT TAN(PI()+1);
274 class OOp_Tan
: public OUnaryOperator
277 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
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:
285 > SELECT ACOS(1.0001);
290 class OOp_ACos
: public OUnaryOperator
293 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
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:
301 > SELECT ASIN('foo');
304 class OOp_ASin
: public OUnaryOperator
307 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
311 Returns the arc tangent of X, that is, the value whose tangent is X:
318 class OOp_ATan
: public OUnaryOperator
321 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
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);
329 > SELECT ATAN2(PI(),0);
333 class OOp_ATan2
: public OBinaryOperator
336 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
340 Returns the argument X, converted from radians to degrees:
342 > SELECT DEGREES(PI());
345 class OOp_Degrees
: public OUnaryOperator
348 virtual ORowSetValue
operate(const ORowSetValue
& lhs
= ORowSetValue()) const SAL_OVERRIDE
;
352 Returns the argument X, converted from degrees to radians:
354 > SELECT RADIANS(90);
358 class OOp_Radians
: public OUnaryOperator
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: */