4.3.2.5. Numeric functions
The following functions support number operations.
- decimal( n, scale )
Returns a number with the specified scale.
表4.50 Parameters
Parameter Type n
number
scale
number
in the range[−6111..6176]
Examples
decimal( 1/3, 2 ) = .33 decimal( 1.5, 0 ) = 2 decimal( 2.5, 0 ) = 2
- floor( n )
Returns the greatest integer that is less than or equal to the specified number.
表4.51 Parameters
Parameter Type n
number
Examples
floor( 1.5 ) = 1 floor( -1.5 ) = -2
- ceiling( n )
Returns the smallest integer that is greater than or equal to the specified number.
表4.52 Parameters
Parameter Type n
number
Examples
ceiling( 1.5 ) = 2 ceiling( -1.5 ) = -1
- abs( n )
Returns the absolute value.
表4.53 Parameters
Parameter Type n
number
,days and time duration
, oryears and months duration
Examples
abs( 10 ) = 10 abs( -10 ) = 10 abs( @"PT5H" ) = @"PT5H" abs( @"-PT5H" ) = @"PT5H"
- modulo( dividend, divisor )
Returns the remainder of the division of the dividend by the divisor. If either the dividend or divisor is negative, the result is of the same sign as the divisor.
注記This function is also expressed as
modulo(dividend, divisor) = dividend - divisor*floor(dividen d/divisor)
.表4.54 Parameters
Parameter Type dividend
number
divisor
number
Examples
modulo( 12, 5 ) = 2 modulo( -12,5 )= 3 modulo( 12,-5 )= -3 modulo( -12,-5 )= -2 modulo( 10.1, 4.5 )= 1.1 modulo( -10.1, 4.5 )= 3.4 modulo( 10.1, -4.5 )= -3.4 modulo( -10.1, -4.5 )= -1.1
- sqrt( number )
Returns the square root of the specified number.
表4.55 Parameters
Parameter Type n
number
Example
sqrt( 16 ) = 4
- log( number )
Returns the logarithm of the specified number.
表4.56 Parameters
Parameter Type n
number
Example
decimal( log( 10 ), 2 ) = 2.30
- exp( number )
Returns Euler’s number
e
raised to the power of the specified number.表4.57 Parameters
Parameter Type n
number
Example
decimal( exp( 5 ), 2 ) = 148.41
- odd( number )
Returns
true
if the specified number is odd.表4.58 Parameters
Parameter Type n
number
Examples
odd( 5 ) = true odd( 2 ) = false
- even( number )
Returns
true
if the specified number is even.表4.59 Parameters
Parameter Type n
number
Examples
even( 5 ) = false even ( 2 ) = true