Purpose
TO_BINARY_FLOAT() returns a single-precision floating-point number.
Note
The conversion from a string or a value of the NUMBER data type to a value of the BINARY_FLOAT data type may not be accurate, because the string and NUMBER data types use decimal precision, while BINARY_FLOAT uses binary precision. If the precision of a BINARY_DOUBLE value is higher than that supported by BINARY_FLOAT, the conversion from BINARY_DOUBLE to BINARY_FLOAT is inaccurate.
Syntax
TO_BINARY_FLOAT(expr [, fmt [, 'nlsparam' ] ])
Parameters
| Parameter | Description |
|---|---|
| expr | A string or value of the NUMBER, BINARY_FLOAT, or BINARY_DOUBLE data type. |
| expr | The format of the return value. This parameter is optional. If you do not specify fmt, n is converted to a VARCHAR2 value. For information about values for fmt, see “Values for fmt”. |
| nlsparam | The decimal character, group separator, local currency symbol, and international currency symbol. This parameter is optional. |
Note
The optional fmt and nlsparam parameters take effect only when expr is a string. They serve the same purpose as for TO_CHAR(number). When expr is of the BINARY_DOUBLE data type, the function returns expr.
Return type
The return type is BINARY_FLOAT.
Examples
The following example converts 123.123 to a single-precision floating-point number.
obclient> SELECT TO_BINARY_FLOAT('123.123') FROM DUAL;
+----------------------------+
| TO_BINARY_FLOAT('123.123') |
+----------------------------+
| 1.23123001E+002 |
+----------------------------+
1 row in set