openmolecules.org

 
Today's Messages (on)  | Unanswered Messages (off)

Forum: Functionality
 Topic: Round numbers by decimal places?
Re: Round numbers by decimal places? [message #2455 is a reply to message #2447] Sun, 07 December 2025 12:46
nbehrnd is currently offline  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



Current Time: Mon Dec 08 03:07:53 CET 2025

Total time taken to generate the page: 0.48377 seconds