Purpose
This function returns a single-precision floating-point number.
Note
Conversion from a string or NUMBER to BINARY_FLOAT may not be precise because NUMBER and character types use decimal precision to represent numbers, while BINARY_FLOAT uses binary precision. If the precision of a BINARY_DOUBLE value exceeds the precision supported by BINARY_FLOAT, the conversion from BINARY_DOUBLE to BINARY_FLOAT is not precise.
Syntax
TO_BINARY_FLOAT(expr [, fmt [, 'nlsparam' ] ])
Parameters
Parameter |
Description |
|---|---|
| expr | The data of the string, NUMBER, BINARY_FLOAT, or BINARY_DOUBLE type. |
| expr | The output format parameter. Optional. If you omit fmt, n is converted to a VARCHAR2 value. For more information about the values, see the description of the fmt parameter. |
| nlsparam | Defines the decimal character, group separator, local currency symbol, and international currency symbol. Optional. |
Note
When expr is a string, the optional fmt and nlsparam parameters are valid. They function the same as the TO_CHAR (number) function. When expr is a BINARY_FLOAT, the function returns expr.
Return type
Returns data of the BINARY_FLOAT type.
Examples
Convert the string 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
