The CAST_FROM_BINARY_FLOAT function returns the BINARY_FLOAT value in RAW binary format.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this function.
Syntax
UTL_RAW.CAST_FROM_BINARY_FLOAT(
n IN BINARY_FLOAT,
endianess IN PLS_INTEGER DEFAULT 1)
RETURN RAW;
Parameters
| Parameter | Description |
|---|---|
| n | The BINARY_FLOAT value. |
| endianess | A BINARY_INTEGER value indicating the byte order. The function supports the following defined constants:
big_endian. When machine_endian is specified, the effect is the same as specifying big_endian on a big-endian system or little_endian on a little-endian system. |
Return value
The binary representation of the BINARY_FLOAT value in RAW format.
Considerations
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 specifies how the bytes of theBINARY_FLOATvalue are mapped to the bytes of theRAWvalue, as shown in the following matrix. In the matrix,rb0 ~ rb3represent the bytes in theRAWvalue, andfb0 ~ fb3represent 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 theBINARY_FLOATparameter are directly copied to theRAWreturn value. If you specifybig_endianon a big-endian system orlittle_endianon a little-endian system, the effect is the same.
Examples
obclient> SELECT UTL_RAW.CAST_FROM_BINARY_FLOAT(0) FROM DUAL;
+-----------------------------------+
| UTL_RAW.CAST_FROM_BINARY_FLOAT(0) |
+-----------------------------------+
| 00000000 |
+-----------------------------------+
1 row in set
obclient> SELECT UTL_RAW.CAST_FROM_BINARY_FLOAT(1.234) FROM DUAL;
+---------------------------------------+
| UTL_RAW.CAST_FROM_BINARY_FLOAT(1.234) |
+---------------------------------------+
| 3F9DF3B6 |
+---------------------------------------+
1 row in set
obclient> SELECT UTL_RAW.CAST_FROM_BINARY_FLOAT(-1.234) FROM DUAL;
+----------------------------------------+
| UTL_RAW.CAST_FROM_BINARY_FLOAT(-1.234) |
+----------------------------------------+
| BF9DF3B6 |
+----------------------------------------+
1 row in set
