The CAST_TO_BINARY_FLOAT function converts a BINARY_FLOAT value in the binary RAW representation into a BINARY_FLOAT value.
Syntax
UTL_RAW.CAST_TO_BINARY_FLOAT (
r IN RAW
endianess IN PLS_INTEGER DEFAULT 1)
RETURN BINARY_FLOAT;
Parameters
| Parameter | Description |
|---|---|
| r | The binary representation of BINARY_FLOAT. |
| endianess | The BINARY_INTEGER value that represents big_endian or little-endian. The default value is big_endian. |
Return values
The BINARY_FLOAT value is returned.
Usage notes
If the
RAWparameter exceeds 4 bytes in length, only the first 4 bytes are used and the remaining bytes are ignored. If the result is-0,+0is returned. If the result isNaN, the return value isBINARY_FLOAT_NAN.If the
RAWparameter is less than 4 bytes in length, theVALUE_ERRORexception is thrown.The following list shows the mapping between a 4-byte
BINARY_FLOATvalue and the IEEE 754 single-precision format:byte 0: bit 31–bit 24 byte 1: bit 23–bit 16 byte 2: bit 15–bit 8 byte 3: bit 7–bit 0The
endianessparameter describes howBINARY_FLOATbytes are mapped toRAWbytes, as shown in the following matrix.rb0–rb3are theRAWbytes, andfb0–fb3are theBINARY_FLOATbytes.endianess rb0 rb1 rb2 rb3 big_endian fb0 fb1 fb2 fb3 little_endian fb3 fb2 fb1 fb0 For
machine-endian, the 4 bytes of theRAWparameter are copied directly into the returnBINARY_FLOATvalue. Passingbig_endianon a big-endian machine has the same effect as passinglittle_endianon a little-endian machine.
Examples
obclient> SELECT UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD') FROM DUAL;
+-----------------------------------------+
| UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD') |
+-----------------------------------------+
| 3.33317925E-038 |
+-----------------------------------------+
1 row in set
obclient> SELECT UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD', 2) FROM DUAL;
+-------------------------------------------+
| UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD',2) |
+-------------------------------------------+
| -6.08415641E-002 |
+-------------------------------------------+
1 row in set
obclient> SELECT UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD', 3) FROM DUAL;
+-------------------------------------------+
| UTL_RAW.CAST_TO_BINARY_FLOAT('13579BD',3) |
+-------------------------------------------+
| -6.08415641E-002 |
+-------------------------------------------+
1 row in set