TO_BINARY_FLOAT

Syntax

Description of the illustration to_binary_float.gif

Description of the illustration to_binary_float.eps

Purpose

TO_BINARY_FLOAT converts expr to a single-precision floating-point number.

If expr or return_value evaluate to the following character strings, then the function converts them as follows:

You cannot use a floating-point number format element (F, f, D, or d) in a character string expr.

Conversions from character strings or NUMBER to BINARY_FLOAT can be inexact, because the NUMBER and character types use decimal precision to represent the numeric value and BINARY_FLOAT uses binary precision.

Conversions from BINARY_DOUBLE to BINARY_FLOAT are inexact if the BINARY_DOUBLE value uses more bits of precision than supported by the BINARY_FLOAT.

See Also: TO_CHAR (number) and “Floating-Point Numbers

Examples

Using table float_point_demo created for TO_BINARY_DOUBLE, the following example converts a value of data type NUMBER to a value of data type BINARY_FLOAT:

SELECT dec_num, TO_BINARY_FLOAT(dec_num)
  FROM float_point_demo;

   DEC_NUM TO_BINARY_FLOAT(DEC_NUM)
---------- ------------------------
   1234.56               1.235E+003

The following example returns the default value of 0 because the specified expression cannot be converted to a BINARY_FLOAT value:

SELECT TO_BINARY_FLOAT('2oo' DEFAULT 0 ON CONVERSION ERROR) "Value"
  FROM DUAL;

     Value
----------
         0