[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to format an array

Li Chen

10/19/2006 7:49:00 PM

Hi all,

I have an array [1.0, 2.0, 3, 4,5,6]. I want to format all the elements
within the array into to this format "%5.3f", that is 5
spaces/characters for each number/element, followed by 3 floating
points. Any help will be appreciate.

Li

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

5 Answers

noah.easterly@gmail.com

10/19/2006 7:57:00 PM

0

[1.0, 2.0, 3, 4,5,6].map { |num| "%5.3f" % num } #=> ["1.000", "2.000",
"3.000", "4.000", "5.000", "6.000"]

On Oct 19, 3:49 pm, Li Chen <chen_...@yahoo.com> wrote:
> Hi all,
>
> I have an array [1.0, 2.0, 3, 4,5,6]. I want to format all the elements
> within the array into to this format "%5.3f", that is 5
> spaces/characters for each number/element, followed by 3 floating
> points. Any help will be appreciate.
>
> Li
>
> --
> Posted viahttp://www.ruby-....

Peter Szinek

10/19/2006 8:04:00 PM

0

Hello,

Li Chen wrote:
> Hi all,
>
> I have an array [1.0, 2.0, 3, 4,5,6]. I want to format all the elements
> within the array into to this format "%5.3f", that is 5
> spaces/characters for each number/element, followed by 3 floating
> points. Any help will be appreciate.

[1.0, 2.0, 3, 4,5,6].map { |n| sprintf "%5.3f", n }

Peter
http://www.rubyra...



DVH

11/7/2013 7:46:00 PM

0

On 07/11/2013 17:58, Bill wrote:
> On Thu, 7 Nov 2013 12:44:21 -0500, "BurfordTJustice"
> <burford@hubdub.mo> wrote:
>
>> The European Central Bank (ECB) cuts its main interest rate to 0.25 percent
>>from 0.50 percent on Thursday, sending the euro sharply lower.
>>
>> The announcement - unexpected by many - was followed by a press conference
>> with ECB President Mario Draghi, who insisted the rate cut was in line with
>> previous forward guidance.
>
> Well UK growth is the best in Europe, and the BofE rate remains at
> 0.5% so the Europeans are obviously trying to attract some of that
> 'hot money' we keep hearing about.
>

Hot money chases higher interest rates, so no.

The ECB is fretting about deflation caused by the German surplus, and to
a lesser extent by the eurozone surplus.

abelard

11/7/2013 7:52:00 PM

0

On Thu, 07 Nov 2013 19:46:12 +0000, DVH <dvh@vhvhvhvh.com> wrote:

>On 07/11/2013 17:58, Bill wrote:
>> On Thu, 7 Nov 2013 12:44:21 -0500, "BurfordTJustice"
>> <burford@hubdub.mo> wrote:
>>
>>> The European Central Bank (ECB) cuts its main interest rate to 0.25 percent
>>>from 0.50 percent on Thursday, sending the euro sharply lower.
>>>
>>> The announcement - unexpected by many - was followed by a press conference
>>> with ECB President Mario Draghi, who insisted the rate cut was in line with
>>> previous forward guidance.
>>
>> Well UK growth is the best in Europe, and the BofE rate remains at
>> 0.5% so the Europeans are obviously trying to attract some of that
>> 'hot money' we keep hearing about.
>>
>
>Hot money chases higher interest rates, so no.
>
>The ECB is fretting about deflation caused by the German surplus, and to
>a lesser extent by the eurozone surplus.

the euro was already too high and yet it has been climbing
since july...this rate cut has had very little effect so far...



--
www.abelard.org
























---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www...

DVH

11/7/2013 7:59:00 PM

0

On 07/11/2013 19:51, abelard wrote:
> On Thu, 07 Nov 2013 19:46:12 +0000, DVH <dvh@vhvhvhvh.com> wrote:
>
>> On 07/11/2013 17:58, Bill wrote:
>>> On Thu, 7 Nov 2013 12:44:21 -0500, "BurfordTJustice"
>>> <burford@hubdub.mo> wrote:
>>>
>>>> The European Central Bank (ECB) cuts its main interest rate to 0.25 percent
>>> >from 0.50 percent on Thursday, sending the euro sharply lower.
>>>>
>>>> The announcement - unexpected by many - was followed by a press conference
>>>> with ECB President Mario Draghi, who insisted the rate cut was in line with
>>>> previous forward guidance.
>>>
>>> Well UK growth is the best in Europe, and the BofE rate remains at
>>> 0.5% so the Europeans are obviously trying to attract some of that
>>> 'hot money' we keep hearing about.
>>>
>>
>> Hot money chases higher interest rates, so no.
>>
>> The ECB is fretting about deflation caused by the German surplus, and to
>> a lesser extent by the eurozone surplus.
>
> the euro was already too high and yet it has been climbing
> since july...this rate cut has had very little effect so far...

I can't say I'm very fussed. I've done my European travels for the year.