Purpose
You can call this function to return a single-precision floating-point number.
Note
The conversion from a string or a value of the
NUMBERdata type to a value of theBINARY_FLOATdata type may not be accurate, because the string andNUMBERdata types use decimal precision, whileBINARY_FLOATuses binary precision. If the precision of aBINARY_DOUBLEvalue is higher than that supported byBINARY_FLOAT, the conversion fromBINARY_DOUBLEtoBINARY_FLOATis 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
fmtandnlsparamparameters take effect only whenexpris a string. They serve the same purpose as forTO_CHAR(number). Whenexpris of theBINARY_DOUBLEdata type, the function returnsexpr.
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