Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= TO_BINARY_DOUBLE

`TO_BINARY_DOUBLE` 将数值、二进制浮点数或文本转换为双精度 `BINARY_DOUBLE`。单参数的文本形式支持十进制和科学记数法。如需解析带格式的文本,可在第二个参数中传入数值格式模型。

[source,sql]
----
SELECT TO_BINARY_DOUBLE('1.25e200') AS scientific,
TO_BINARY_DOUBLE('9,876.5', '9,999.9') AS formatted,
TO_BINARY_DOUBLE(16777217::NUMBER) =
TO_BINARY_DOUBLE(16777216::NUMBER) AS equal_after_conversion
FROM dual;
----

查询依次返回 `1.25e+200`、`9876.5` 和 `f`。双精度可以区分比较中的两个整数。将已舍入的 xref:master/oracle_compatibility/compat_to_binary_float_function.adoc[BINARY_FLOAT] 转为双精度时,仍然保留舍入后的值。
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= TO_BINARY_FLOAT

`TO_BINARY_FLOAT` 将输入转换为单精度 `BINARY_FLOAT`。对于数值、二进制浮点数或 `'1.25'`、`'1.25e6'` 这样的文本,使用 `TO_BINARY_FLOAT(value)`。如果输入包含格式模型所描述的分隔符,使用 `TO_BINARY_FLOAT(text, format)`。

[source,sql]
----
SELECT TO_BINARY_FLOAT('1,234.5', '9,999.9') AS formatted,
TO_BINARY_FLOAT(16777217::NUMBER) =
TO_BINARY_FLOAT(16777216::NUMBER) AS rounded,
TO_BINARY_FLOAT(NULL::TEXT) IS NULL AS null_preserved
FROM dual;
----

查询依次返回 `1234.5`、`t` 和 `t`。单精度会将 `16777217` 舍入为 `16777216`。如果需要区分这两个整数,可以使用 xref:master/oracle_compatibility/compat_to_binary_double_function.adoc[TO_BINARY_DOUBLE]。
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= TO_BINARY_DOUBLE

`TO_BINARY_DOUBLE` converts its argument to double-precision `BINARY_DOUBLE`. It accepts numbers, binary floating-point values, and text. The one-argument text form accepts decimal and scientific notation. Supply a numeric format model as the second argument to interpret formatted text.

[source,sql]
----
SELECT TO_BINARY_DOUBLE('1.25e200') AS scientific,
TO_BINARY_DOUBLE('9,876.5', '9,999.9') AS formatted,
TO_BINARY_DOUBLE(16777217::NUMBER) =
TO_BINARY_DOUBLE(16777216::NUMBER) AS equal_after_conversion
FROM dual;
----

The query returns `1.25e+200`, `9876.5`, and `f`. Double precision distinguishes both integers in the comparison. Converting an already rounded xref:master/oracle_compatibility/compat_to_binary_float_function.adoc[BINARY_FLOAT] to double precision keeps the rounded value.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= TO_BINARY_FLOAT

`TO_BINARY_FLOAT` converts its argument to a single-precision `BINARY_FLOAT`. Use `TO_BINARY_FLOAT(value)` for numeric or binary floating-point inputs, or for text in a form such as `'1.25'` or `'1.25e6'`. Use `TO_BINARY_FLOAT(text, format)` when a string contains delimiters described by a numeric format model.

[source,sql]
----
SELECT TO_BINARY_FLOAT('1,234.5', '9,999.9') AS formatted,
TO_BINARY_FLOAT(16777217::NUMBER) =
TO_BINARY_FLOAT(16777216::NUMBER) AS rounded,
TO_BINARY_FLOAT(NULL::TEXT) IS NULL AS null_preserved
FROM dual;
----

The query returns `1234.5`, `t`, and `t`. Single precision rounds `16777217` to `16777216`. When that distinction matters, see xref:master/oracle_compatibility/compat_to_binary_double_function.adoc[TO_BINARY_DOUBLE].
Loading