How to format decimals on the fly (for EOF blocks)?

Hello, I’m facing a problem where, for instance, 7mcg of Nutrient is
required per day. It’s scaled in the db to 3 (or more) decimal places,
but on the page, often there will show

Nutrient 0 mcg 8%

– otherwise … 0.4423 mcg 8%

My figures are for demonstration only :slight_smile:

Is there a way to covert the latter mcg figure to 0.4 on the fly? Or do
I need to work on the database, since these are mainly for string <<EOF
output?

sprintf !

Jesse C. wrote:

Hello, I’m facing a problem where, for instance, 7mcg of Nutrient is
required per day. It’s scaled in the db to 3 (or more) decimal places,
but on the page, often there will show

Nutrient 0 mcg 8%

– otherwise … 0.4423 mcg 8%

My figures are for demonstration only :slight_smile:

Is there a way to covert the latter mcg figure to 0.4 on the fly? Or do
I need to work on the database, since these are mainly for string <<EOF
output?