Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How to format decimals on the fly (for EOF blocks)?

Reply
Thread Tools

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

 
 
Jesse Crockett
Guest
Posts: n/a
 
      08-28-2008
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?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jesse Crockett
Guest
Posts: n/a
 
      08-28-2008
sprintf !

Jesse Crockett 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
>
> 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?


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse Java 67 03-14-2012 12:21 AM
ifstream eof not reporting eof? SpreadTooThin C++ 10 06-15-2007 08:49 AM
if EOF = -1, can't a valid character == EOF and cause problems? Kobu C Programming 10 03-04-2005 10:40 PM
String format, thousand separator and decimals hansiman ASP .Net 1 10-08-2004 07:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57