NUMERIC関数は数値(integer、long、float、double、biginteger、bigdecimal)を返します。これらは一般的にNUMERIC値を入力としますが、文字列を入力とするものもあります。 

Standard Numeric Operators (+ - * /)

これらの演算子は x を {integer, long, float, double, biginteger, bigdecimal} の中でとり、戻り値の型は x と同じです。 

BIGDECIMALでない算術関数の精度とスケールは、Javaの結果と一致します。BIGDECIMAL演算の結果は、max(16, dividend.scale + divisor.precision + 1)の優先スケールを使用する除算を除いて、Javaと一致します。

Other Numeric Functions

Function

Definition

Data Type Constraint

ABS(x)

Absolute value of x

See standard numeric operators above

ACOS(x)

Arc cosine of x

x in {double, bigdecimal}, return type is double

ASIN(x)

Arc sine of x

x in {double, bigdecimal}, return type is double

ATAN(x)

Arc tangent of x

x in {double, bigdecimal}, return type is double

ATAN2(x,y)

Arc tangent of x and y

x, y in {double, bigdecimal}, return type is double

CEILING(x)

Ceiling of x

x in {double, float}, return type is double

COS(x)

Cosine of x

x in {double, bigdecimal}, return type is double

COT(x)

Cotangent of x

x in {double, bigdecimal}, return type is double

DEGREES(x)

Convert x radians to degrees

x in {double, bigdecimal}, return type is double

EXP(x)

e^x

x in {double, float}, return type is double

FLOOR(x)

Floor of x

x in {double, float}, return type is double

FORMATBIGDECIMAL(x, y)

Format x using format y

x is bigdecimal, y is string, returns string

FORMATBIGINTEGER(x, y)

Format x using format y

x is biginteger, y is string, returns string

FORMATDOUBLE(x, y)

Format x using format y

x is double, y is string, returns string

FORMATFLOAT(x, y)

Format x using format y

x is float, y is string, returns string

FORMATINTEGER(x, y)

Format x using format y

x is integer, y is string, returns string

FORMATLONG(x, y)

Format x using format y

x is long, y is string, returns string

LOG(x)

Natural log of x (base e)

x in {double, float}, return type is double

LOG10(x)

Log of x (base 10)

x in {double, float}, return type is double

MOD(x, y)

Modulus (remainder of x / y)

x in {integer, long, float, double, biginteger, bigdecimal}, return type is same as x

PARSEBIGDECIMAL(x, y)

Parse x using format y

x, y are strings, returns bigdecimal

PARSEBIGINTEGER(x, y)

Parse x using format y

x, y are strings, returns biginteger

PARSEDOUBLE(x, y)

Parse x using format y

x, y are strings, returns double

PARSEFLOAT(x, y)

Parse x using format y

x, y are strings, returns float

PARSEINTEGER(x, y)

Parse x using format y

x, y are strings, returns integer

PARSELONG(x, y)

Parse x using format y

x, y are strings, returns long

PI()

Value of Pi

return is double

POWER(x,y)

x to the y power

x in {double, bigdecimal, biginteger}, return is the same type as x

RADIANS(x)

Convert x degrees to radians

x in {double, bigdecimal}, return type is double

RAND()

Return random number in the range 0.0 <= x < 1.0

return is double; while rand() is pushed down to MySQL, PostgreSQL and Oracle, it's not pushed down to Microsoft SQL Server.

RAND_SEED(x)

Return random number using new generator seeded with x

x is integer, returns double

ROUND(x, y)

Round x to y places; negative values of y indicate places to the left of the decimal point

x in {integer, float, double, bigdecimal} y is integer, return is the same type as x

SIGN(x)

1 if x > 0, 0 if x = 0, -1 if x < 0

x in {integer, long, float, double, biginteger, bigdecimal}, return type is integer

SIN(x)

Sine value of x

x in {double, bigdecimal}, return type is double

SQRT(x)

Square root of x

x in {long, double, bigdecimal}, return type is double

TAN(x)

Tangent of x

x in {double, bigdecimal}, return type is double

BITAND(x, y)

Bitwise AND of x and y

x, y in {integer}, return type is integer

BITOR(x, y)

Bitwise OR of x and y

x, y in {integer}, return type is integer

BITXOR(x, y)

Bitwise XOR of x and y

x, y in {integer}, return type is integer

BITNOT(x)

Bitwise NOT of x

x in {integer}, return type is integer

Parsing Numeric Data Types from Strings

CData Virtuality Server は、文字列から数値を解析するために使用できる一連の関数を提供します。各文字列について、文字列の書式を指定する必要があります。これらの関数は、 java.text.DecimalFormat クラスによって確立された規約を使用して、これらの関数で使用できる書式を定義しています。このクラスが数値文字列書式を定義する方法については、 Oracle Java documentationを参照してください。

例えば、java.text.DecimalFormat の規約に従ったフォーマット文字列でこれらの関数を呼び出すと、文字列を解析して必要なデータ型を返すことができます:

Input String

Function Call to Format String

Output Value

Output Data Type

'$25.30'

PARSEDOUBLE(cost, '$#,##0.00;($#,##0.00)')

25.3

double

'25%'

PARSEFLOAT(percent, '#,##0%')

25

float

'2,534.1'

PARSEFLOAT(total, '#,##0.###;-#,##0.###')

2534.1

float

'1.234E3'

PARSELONG(amt, '0.###E0')

1234

long

'1,234,567'

PARSEINTEGER(total, '#,##0;-#,##0')

1234567

integer

入力文字列の正しい書式は、サーバーのロケールによって異なります。パターンは米国英語表記の慣例に従わなければなりません。

Formatting Numeric Data Types as Strings

CData Virtuality Server は、数値データ型を文字列に変換するために使用できる一連の関数を提供します。各文字列について、書式を指定する必要があります。これらの関数は、 java.text.DecimalFormat クラス内で確立された規約を使用して、これらの関数で使用できる書式を定義しています。このクラスが数値文字列書式を定義する方法については、 Oracle Java documentationを参照してください。

例えば、java.text.DecimalFormat の規約に従ったフォーマット文字列とこれらの関数コールを使用することで、数値データ型を文字列にフォーマットすることができます:

Input Value

Input Data Type

Function Call to Format String

Output String

25.3

double

FORMATDOUBLE(cost, '$#,##0.00;($#,##0.00)')

'$25.30'

25

float

FORMATFLOAT(percent, '#,##0%')

'25%'

2534.1

float

FORMATFLOAT(total, '#,##0.###;-#,##0.###')

'2,534.1'

1234

long

FORMATLONG(amt, '0.###E0')

'1.234E3'

1234567

integer

FORMATINTEGER(total, '#,##0;-#,##0')

'1,234,567'

See Also

Check if a String Can Be Cast to a Number Using isNumeric すぐに使えるCREATE ステートメントはこちらをご覧ください。