Decimal Precision


(Allison Enders) #1

Hi, does anyone know how I can change a string to a float value shown out to 4 decimal places? For example a value of 4 should be changed to 4.0000
Thanks!


(Katrin Popova) #2

Hello Allison,

To convert string to float you can use toFloat() function, and also math.round() to round the number with given number of decimal places. For more details regarding the functions you can press F1 and search for Expressions documentation.

Could you please provide me more information why the value of 4 you would like to be represented as decimal?

Regards,
Katrin


(Allison Enders) #3

That was a simplified version of what I actually need. I’m trying to calculate the difference between 2 values. It appears when the decimal goes out more than 10 spaces, the number is automatically rounded. For example 129,645.00000000004 - 129,645 gives me a result of “0” and I need the answer to be precise; so that it should be .00000000004
Thanks!


(Katrin Popova) #4

Hello Allison,

As I said in my previous comment you can use the function math.round(column,10). This means the number will be rounded with 10 decimal places. For example you have two columns A and B containing float numbers. You can specify the expression to be like this:


Result:
image

Regards,
Katrin


(Allison Enders) #5

Thanks for the help. We’ve learned that the default for Ataccama is set to 10 decimal places, so anything over that will be automatically rounded. This explains why the round function didn’t seem to be working for anything great than 10 decimal places.