The CAST_FROM_BINARY_FLOAT function returns a BINARY_FLOAT value in the binary RAW representation.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
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 that indicates the byte order. The defined constants that this function can recognize are as follows:
big_endian. The setting of machine_endian has the same effect as big_endian on a big-endian machine, or has the same effect as little_endian on a little-endian machine. |
Return values
The binary representation (RAW) of a BINARY_FLOAT value is returned.
Considerations
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 theBINARY_FLOATparameter are copied directly into the returnRAWvalue. Passingbig_endianon a big-endian machine has the same effect as passinglittle_endianon a little-endian machine.
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