Oracle Binary_float Datatype

In this Oracle tutorial, we will learn about the binary_float datatype in the oracle database. Also, we will illustrate how to use it to create binary_float columns for a table in oracle.

In this article, we will discuss the binary_float datatype in Oracle 21c and how it can store and manipulate double-precision floating-point numbers.

Introduction to Oracle binary_float Datatype

Single-precision floating-point integers are stored in the built-in data type binary float in Oracle Database. It has an accuracy of roughly 7 decimal digits and stores values using 32 bits.

This form of data is frequently used to hold technical or scientific data that needs floating-point precision.

Because the binary float datatype is fixed-length, regardless of the value recorded, the storage capacity is always 4 bytes. This can be helpful when storing a lot of values or when a fixed quantity of storage is necessary.

Also, check: Oracle Binary_double Datatype

Oracle binary_float datatype Syntax

The syntax for declaring a column of binary_float data type in Oracle 21c is as follows:

column_name BINARY_FLOAT;

where column_name is the name of the column.

Oracle binary_float datatype Example

Here’s an example of using the binary_float datatype in Oracle 21c:

CREATE TABLE employees (
  emp_id NUMBER,
  emp_salary BINARY_FLOAT
);

Now we will insert the values into the following given table

INSERT INTO employees (emp_id , emp_salary) VALUES (1722, 12.141);

select * from employees;
use the binary_float datatype in oracle 21c
use the binary_float datatype in oracle 21c

Now we will use the binary_float datatype in a SQL developer tool using oracle 21c.

Using the binary_float datatype in developer tool
Using the binary_float datatype in a developer tool

Here we will insert the values into a following given table

INSERT INTO customer (customer_id , salary) VALUES (6722, 12.1412);

select * from customer;
insert the values in a table oracle
insert the values in a table oracle

Read: Oracle Binary_double Datatype

Advantages of binary_float datatype

  • Saves Storage Space: Compared to other data types, such as NUMBER or FLOAT, the binary float data type utilises a lot less storage space to hold a value—only 4 bytes—to represent a value.
  • Effective for Scientific and Engineering Data: The Binary Float datatype is frequently used to store scientific and engineering data, where high accuracy is needed for calculations using decimal numbers.
  • Faster Processing: Compared to values stored in variable-length formats, binary float values can be processed more quickly since they are stored in a fixed-length format. Because of this, they are perfect for high-performance computing applications.
  • Compatibility with Other Applications: The binary_float datatype is widely supported by other programming languages and applications, making it easy to integrate with other systems.

Limitations of Binary Float Datatype in Oracle 21c:

  • Low Precision: The precision of the Binary Float datatype is just about 7 decimal digits, which might not be enough for some applications that call for more precision.
  • Due to the data type’s restricted precision, there may be occasional rounding mistakes when performing arithmetic operations on binary float values.
  • Binary Float datatype may not be appropriate for financial applications requiring high precision since rounding errors might result in large disparities in economic computations.

Also, check: Float Datatype in Oracle Database

Storage and performance of Binary Float Datatype in Oracle 21c

  • Binary float takes 4 bytes of memory for storage. It is a compact datatype as a result, which may lower storage needs and boost query performance.
  • Compared to other floating-point datatypes, binary float has a few advantages in terms of performance. It can analyse and send data over a network more quickly than binary double since it takes up less storage space. Also, binary float may execute calculations more quickly than binary double because it has less precision.
  • It’s crucial to remember that binary float has a restricted degree of precision, which means it might not be suitable for all kinds of calculations. Binary double or other datatypes might be a better fit when high precision is required.

Read: Oracle nclob Datatype

Conclusion:

So, in this Oracle tutorial, we understood how to define and use the binary_float Datatype in Oracle Database. And we have also covered a few sample examples related to it.

Also, take a look at some more Oracle tutorials.