Add decimals to double

Hi all,

I’m trying to add 3 decimals to a double (80.5 to 80.500) does anyone know how can I do this? I tried using Round Double but it only displays as many decimals as the double already has.

Hi,

If this is for presentation and you don’t need the numeric type for calculations, then you can convert the column to string and add the 0s.

You can use something like this in Column Expressions node to do that:

dec = regexReplace(column("column1"), "^[\\d]+\\.?", "")
len = dec.length
if (len >= 3)
join(regexReplace(column("column1"), "(^[\\d]+\\.[\\d]{3}).*", "$1"))
else if (len == 2)
join(regexReplace(column("column1"), "(^[\\d]+\\.[\\d]{2}).*", "$1"), "0")
else if (len == 1)
join(regexReplace(column("column1"), "(^[\\d]+\\.[\\d]{1}).*", "$1"), "00")
else
join(column("column1"),".000")

:blush:

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.