The CAST_TO_BINARY_FLOAT function converts a BINARY_FLOAT value represented in RAW binary format to a BINARY_FLOAT value.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this function.
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 a BINARY_FLOAT value. |
| endianess | A BINARY_INTEGER value indicating big_endian or little-endian. The default value is big_endian. |
Return value
The function returns a BINARY_FLOAT value.
Considerations
If the
RAWparameter exceeds 4 bytes, 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 returned value isBINARY_FLOAT_NAN.If the
RAWparameter is less than 4 bytes, an exceptionVALUE_ERRORis raised.The following table 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 how the bytes of aBINARY_FLOATvalue are mapped to the bytes of theRAWparameter, as shown in the following matrix. Here,rb0 ~ rb3refer to the bytes in theRAWparameter, andfb0 ~ fb3refer to the bytes in theBINARY_FLOATvalue.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 directly copied to the return valueBINARY_FLOAT. If you passbig_endianon a big-endian machine orlittle_endianon a little-endian machine, the effect is the same.
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
