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 |
---|---|---|
| Absolute value of x | See standard numeric operators above |
| Arc cosine of x | x in {double, bigdecimal}, return type is double |
| Arc sine of x | x in {double, bigdecimal}, return type is double |
| Arc tangent of x | x in {double, bigdecimal}, return type is double |
| Arc tangent of x and y | x, y in {double, bigdecimal}, return type is double |
| Ceiling of x | x in {double, float}, return type is double |
| Cosine of x | x in {double, bigdecimal}, return type is double |
| Cotangent of x | x in {double, bigdecimal}, return type is double |
| Convert x radians to degrees | x in {double, bigdecimal}, return type is double |
| e^x | x in {double, float}, return type is double |
| Floor of x | x in {double, float}, return type is double |
| Format x using format y | x is bigdecimal, y is string, returns string |
| Format x using format y | x is biginteger, y is string, returns string |
| Format x using format y | x is double, y is string, returns string |
| Format x using format y | x is float, y is string, returns string |
| Format x using format y | x is integer, y is string, returns string |
| Format x using format y | x is long, y is string, returns string |
| Natural log of x (base e) | x in {double, float}, return type is double |
| Log of x (base 10) | x in {double, float}, return type is double |
| Modulus (remainder of x / y) | x in {integer, long, float, double, biginteger, bigdecimal}, return type is same as x |
| Parse x using format y | x, y are strings, returns bigdecimal |
| Parse x using format y | x, y are strings, returns biginteger |
| Parse x using format y | x, y are strings, returns double |
| Parse x using format y | x, y are strings, returns float |
| Parse x using format y | x, y are strings, returns integer |
| Parse x using format y | x, y are strings, returns long |
| Value of Pi | return is double |
| x to the y power | x in {double, bigdecimal, biginteger}, return is the same type as x |
| Convert x degrees to radians | x in {double, bigdecimal}, return type is double |
| 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. |
| Return random number using new generator seeded with x | x is integer, returns double |
| 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 |
| 1 if x > 0, 0 if x = 0, -1 if x < 0 | x in {integer, long, float, double, biginteger, bigdecimal}, return type is integer |
| Sine value of x | x in {double, bigdecimal}, return type is double |
| Square root of x | x in {long, double, bigdecimal}, return type is double |
| Tangent of x | x in {double, bigdecimal}, return type is double |
| Bitwise AND of x and y | x, y in {integer}, return type is integer |
| Bitwise OR of x and y | x, y in {integer}, return type is integer |
| Bitwise XOR of x and y | x, y in {integer}, return type is integer |
| 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 |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
入力文字列の正しい書式は、サーバーのロケールによって異なります。パターンは米国英語表記の慣例に従わなければなりません。
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 |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See Also
Check if a String Can Be Cast to a Number Using isNumeric すぐに使えるCREATE
ステートメントはこちらをご覧ください。