[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: print float number
From: |
lina |
Subject: |
Re: print float number |
Date: |
Thu, 09 Jan 2014 13:56:11 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 |
On Wednesday 08,January,2014 01:36 PM, Bob Proulx wrote:
> Hi lina,
>
> lina wrote:
>> How can I print the 0.05, 0.10 ... 1.0 out, with the step of 0.05
>>
>> Thanks ahead for your suggestions,
>
> First please do not hijack threads. You replied to Chris Down's
> message responding to DanielB about "For loop prints two $values
> instead of one" and then changed the subject but your message isn't
> about anything to do with that thread. If you want to start a new
> thread like you did here please compose a new message. Please don't
> reply to an existing thread to start a new conversation.
Hi Bob, my fault, I didn't realize this was a wrong way to start a new
conversation, by renaming the Subject and deleted everything inside. How
could they figure out it is from that thread?
>
> Second is that this is simply a question and not a bug report.
> Questions should go to the help-bash@gnu.org mailing list.
>
>> How can I print the 0.05, 0.10 ... 1.0 out, with the step of 0.05
>
> As to your question there are many ways to solve the problem. I would
> be inclined to use the GNU seq command.
Very helpful, thanks,
>
> $ seq 0.05 0.05 1.0
> 0.05
> 0.10
> 0.15
> 0.20
> 0.25
> 0.30
> 0.35
> 0.40
> 0.45
> 0.50
> 0.55
> 0.60
> 0.65
> 0.70
> 0.75
> 0.80
> 0.85
> 0.90
> 0.95
> 1.00
>
> However seq is somewhat of a troubled command. It does math with
> floating point and sometimes suffers from the same problems as
> anything that does compter based floating point math with various
> approximation and rounding errors. You must be careful concerning it
> or odd errors will occur.
>
> A related question about for loops in bash is discussed in this FAQ
> entry. It isn't exactly your case but you might be interested in
> reading about the examples it provides.
>
> http://mywiki.wooledge.org/BashFAQ/018
>
> I doubt just printing out these numbers were really your question. If
> you wrote a message to help-bash@gnu.org and described your task in
> more detail there are many people who would be happy to help you use
> bash effectively.
>
> Bob
>
Re: For loop prints two $values instead of one, Greg Wooledge, 2014/01/07