[[*recipeCalories:div=`2000`:mpy=`100`]]%
This question has been answered by BobRay. See the first response.
if (empty($m_val)) {
$m_val = 1;
}
if (!empty($output)) {
$output = (float)$output / (float)$m_val;
} else {
$output = 0;
} }
return (string) round((float)$output * 100 );
[[*recipeCalories:MyPercent=`2000`]]%

[[+nCalories:MyPercent=`2000`]]%
[[!+nCalories:MyPercent=`2000`]]%
Initially, your tag was with a *. If you changed it because the code is in a Tpl chunk, the output modifier might not work in that case. You could try it uncached:
[[!+nCalories:MyPercent=`2000`]]%
I'm not sure it would work. If not, let me know and I'll give you a non-output-modifier method to try.
/* MyPercent snippet code */
$m_val = $modx->getOption('m_val', $scriptProperties, '');
$value = $modx->getOption('value', $scriptProperties, '');
/* prevent division by 0 error */
if (empty($m_val)) {
$m_val = 1;
}
if (!empty($value)) {
$output = (float)$value / (float)$m_val;
} else {
$output = 0;
}
return (string)round((float)$output * 100);
[[MyPercent? &value=`[[*recipeCalories]]` &m_val=`2000`]]%
[[MyPercent? &value=`[[*recipeCalories]]` &m_val=`2000`]]%