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

J

Jesse Crockett

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 :)

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?
 
J

Jesse Crockett

sprintf !

Jesse said:
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 :)

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top