bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print float number


From: Bob Proulx
Subject: Re: print float number
Date: Tue, 7 Jan 2014 22:36:54 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

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.

Second is that this is simply a question and not a bug report.
Questions should go to the address@hidden 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.

  $ 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 address@hidden and described your task in
more detail there are many people who would be happy to help you use
bash effectively.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]