| Round numbers by decimal places? [message #2445] |
Wed, 19 November 2025 22:23  |
Santora V
Messages: 8 Registered: March 2024
|
Junior Member |
|
|
Is there a simple way to round numbers by decimal places rather than significant figures? I have a column with values that range from 1 to several digits (first list below), and I want to round them as shown in the 2nd list.
Perhaps a find and replace search?
Thanks!
1.1
11.2
11.6
101.2
101.6
Round to:
1
11
12
101
102
|
|
|
|
|
|
|
|
| Re: Round numbers by decimal places? [message #2455 is a reply to message #2447] |
Sun, 07 December 2025 12:46  |
nbehrnd
Messages: 235 Registered: June 2019
|
Senior Member |
|
|
Hello Santora
As an example for a small set of 10 molecules, the dwam macro attached proceeds in a sequence to
- compute the molecular weight, like one would click over Chemistry -> From Chemical Structure -> Calculate Propeties -> Total average molweight, to create a temporary new column. DW 06.0.5.02 populates this one with three decimals if the third one is 1-9, a 0 leads to truncation
- creates a new column `MW_rounded` of calculated values (here: to round the molecular weight to 0 decimals)
- deletes the earlier, now no longer needed column of molecular weights with up to 3 decimals.
The .dwam is the result of recording the macro (macro -> start recording, later macro -> end recording and export macro). In the step to create the column about rounded molecular weights, during recording the macro, one can opt-in to directly overwrite the already existing column about molecular weight, too (see the second macro). This simplifies the macro file; using one, or the other route depends on your preferences.
Best regards
Norwid
|
|
|
|