cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Never use the float data type

lizou
Contributor II

select float('92233464567.33') returns

92,233,466,000

I am expected result will be around 92,233,464,567.xx

therefore, float data type should be avoided.

Use double or decimal works as expected.

But I see float data type is widely used assuming most numeric values are < 1 billion.

image

1 REPLY 1

Prabakar
Databricks Employee
Databricks Employee

Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly.

Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type range can be represented exactly with precision and scale.

So its always better you use Decimal instead of float.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group