# Divide a positive or negative decimal value

Hi! I've used the program for quite some time, but I've only recently started experimenting with actions (previously I'd handled everything manually).

I'm looking to halve a set of values in the COMMENT field. They're all positive or negative values with two numbers following the decimal point. As an example list, I have the following values:
+7.15
-0.06
+1.41
+0.00
-3.55

I'd like to set these values to half of their respective starting values using an action, if possible. I've experimented myself and have the following so far:

1. This removes the decimal point and effectively multiplies all values by 100.
Format value "COMMENT".
\$replace(%comment%,.,)

2. This halves the new values.
Format value "COMMENT"
\$div(%comment%,2)

The third step is currently the problem. I'd like to match the input formatting with the output formatting. This means all values should have either a + or - before them (including +0.00), and should have a decimal point followed by two digits, even if they're both zeroes. It also might be worth noting that the values will never exceed +90 or -90, so a scenario with three digits before the decimal point is not possible.

I've been experimenting with \$ifgreater and \$left to try and calculate a new value with a decimal point, but my results so far have not even been close to what I'd expect, but that's probably because I'm new at this.

Any help would be greatly appreciated, and thank you for taking the time to read this.

Perhaps you find inspiration here:

Try this format string:
\$regexp(%comment%,'([+-]).+',\$1)\$regexp(\$num(\$regexp(\$div(\$replace(%comment%,.,),2),'(-*)(.+)',\$2),3),'(\d+)(\d\d\$)',\$1.\$2)

@ryerman That worked perfectly, thank you. I tested it on ~50 example files and the results were all correct!

@ohrenkino Thank you for that link. Not only did it help me get further on my own trials, but it also gave me a few ideas on how to creatively use actions in the program, which will be invaluable in the future.

I greatly appreciate the help. Thank you both!