Hi. I need some help on Float Data types. Can someone articulate to me (without quoting the typical online definition ) what a Float Data type loses in its precision? Specifically, does it start to round the value after a certain length digit?
For example:

If the actual data value was 12,389,999.83 would the float data type round it to 12,390,000?

It has to do with binary math, hardware, and speed. There is no way to represent 1/3 in binary as the decimal repeats indefinitely. The calculation 1/3 * 2 must be limited otherwise the computer will churn for eternity. That's where standards come in.
Every computer system should not arbitrarily pick how to handle 1/3 as that would cause compatibility issues between systems. We have standards like IEEE 1987 which recommends how the systems should handle 1/3.

Keep in mind, the science behind floating point calculations is far more complicated than handling 1/3. There are other technical challenges with floating point math and you can certainly learn the subject. This will get you started.

Sorry to ask, but can you provide the risks of using flat as it relates to financial data? In short, my worry is that financial numbers within a float datatype will not reconciled to true balances. Is that true? If so, after how many digits does it get impacted?
Is there any concern with my example above?

Sorry to ask, but can you provide the risks of using flat as it relates to financial data? In short, my worry is that financial numbers within a float datatype will not reconciled to true balances. Is that true? If so, after how many digits does it get impacted?
Is there any concern with my example above?

I would if I could, but this is a "black box" data system. I need to know what the risk is to using the float datatype with financial numbers. At what point does it impact The true value. I have no option to change it to decimal point when the data is captured

I would if I could, but this is a "black box" data system. I need to know what the risk is to using the float datatype with financial numbers. At what point does it impact The true value. I have no option to change it to decimal point when the data is captured

As far as I know it is not a straight forward answer as it depends on how you are currently handling precision and types of number used in the calculations.

It's not about decimal point precision. It's how base 10 numbers are represented in binary as not all base 10 number can be represented in binary.

Thanks. That helps a little bit, but I'm still not there incomplete understanding. It helps to know that is not a "decibel thing". Do you think you can come up with some examples of where the precision of the conversion between float and a small Would result
in an issue where financials might not balance?

Thanks. That helps a little bit, but I'm still not there incomplete understanding. It helps to know that is not a "decibel thing". Do you think you can come up with some examples of where the precision of the conversion between float and a small Would result
in an issue where financials might not balance?

The margin of error is based on the number and the arithmetic.

Float is not a data type you can use if you want a precise balance. It is very rare in an application you can use float in most applications. Float is an approximate data type. You can should use numerical/decimal to get correct numeric number.

Yes, that's what this entire discussion is about. We know what it is and why. We know we 'can should' use decimal. However as explained above, this is a black-box cots application. The issue is, we cannot recast the data type, and we are looking for impacts.
The question has been answered.

Member

2 Points

6 Posts

## Issues with Float Data Thpes

Aug 04, 2017 09:22 PM|Breaker2112|LINK

Hi. I need some help on Float Data types. Can someone articulate to me (without quoting the typical online definition ) what a Float Data type loses in its precision? Specifically, does it start to round the value after a certain length digit?

For example:

If the actual data value was 12,389,999.83 would the float data type round it to 12,390,000?

All-Star

31701 Points

11805 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 12:47 PM|mgebhard|LINK

It has to do with binary math, hardware, and speed. There is no way to represent 1/3 in binary as the decimal repeats indefinitely. The calculation 1/3 * 2 must be limited otherwise the computer will churn for eternity. That's where standards come in. Every computer system should not arbitrarily pick how to handle 1/3 as that would cause compatibility issues between systems. We have standards like IEEE 1987 which recommends how the systems should handle 1/3.

Keep in mind, the science behind floating point calculations is far more complicated than handling 1/3. There are other technical challenges with floating point math and you can certainly learn the subject. This will get you started.

http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Member

2 Points

6 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 12:54 PM|Breaker2112|LINK

All-Star

31701 Points

11805 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 12:59 PM|mgebhard|LINK

Use the decimal type for financial calculations.

Member

2 Points

6 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 01:05 PM|Breaker2112|LINK

All-Star

31701 Points

11805 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 01:25 PM|mgebhard|LINK

As far as I know it is not a straight forward answer as it depends on how you are currently handling precision and types of number used in the calculations.

It's not about decimal point precision. It's how base 10 numbers are represented in binary as not all base 10 number can be represented in binary.

Member

2 Points

6 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 01:50 PM|Breaker2112|LINK

All-Star

31701 Points

11805 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 04:06 PM|mgebhard|LINK

The margin of error is based on the number and the arithmetic.

Member

2 Points

6 Posts

## Re: Issues with Float Data Thpes

Aug 05, 2017 11:39 PM|Breaker2112|LINK

All-Star

122272 Points

9716 Posts

Moderator

## Re: Issues with Float Data Thpes

Aug 07, 2017 01:18 PM|limno|LINK

Float is not a data type you can use if you want a precise balance. It is very rare in an application you can use float in most applications. Float is an approximate data type. You can should use numerical/decimal to get correct numeric number.

Format your SQL query with instant sql formatter:

http://www.dpriver.com/pp/sqlformat.htm

Member

2 Points

6 Posts

## Re: Issues with Float Data Thpes

Aug 10, 2017 09:39 AM|Breaker2112|LINK