Fixed number of digits

Hi,

How to replace values in a column so that hey have for instance 2 digits. It is not realy about formatting the number.

For example I have numbers like: 1.23568 ; 1.5 ; 0; 5 ; etc.

I want to replace the values by a number with 2 decimals: 1.24 ; 1.50; 0.00; 5.00; etc.

How can I achieve that ? The format option just alters the presentation so that does not work.

Round as usually, then use padend() to append missing zeroes to the right.

keepbefore(round([Data],2), '.') & '.' & padend(keepafter(round([Data],2), '.'), '0', 2)

format-decimals.morph (1.6 KB)

image

2 Likes

Ok thanks, I shall try that !

Hi Dmitry,

Can I also achieve this when I set the format for each column and then export to CSV. This seems only to export to 2 decimal digits. Does the format stays in alle tabs ans transformations once it is set ?
Can I do something similar for N-fixed digits (other formatting)?

Eg.

The “Preserve formatting” option in “Export to delimited text file” will export exactly as formatted in EasyMorph. For all other formats customer formatting should be done similarly to the expressions I used above.

1 Like