|
Home > Archive > Unix Shell > November 2006 > Bash and floating point math
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Bash and floating point math
|
|
| Antonio Maschio 2006-11-23, 1:16 pm |
| Hi,
I don't want to stress anyone, but AFAIK kh93 deals with floating point
math (news from bash FAQ). Just for curiosity:
Do you know if bash will, one distant day, have the same feature?
Do you know if this has been planned by bash maintainers?
Thanks in advance.
-- Antonio
| |
| Antonio Maschio 2006-11-23, 1:16 pm |
| of course kh92 should stand for ksh93 !
| |
| Antonio Maschio 2006-11-23, 1:16 pm |
| Antonio Maschio wrote:
> of course kh92 should stand for ksh93 !
another mistake: kh93 for kh92.
| |
| loic-dev@gmx.net 2006-11-23, 7:19 pm |
| Hello Antonio,
> I don't want to stress anyone, but AFAIK kh93 deals with floating point
> math (news from bash FAQ). Just for curiosity:
>
> Do you know if bash will, one distant day, have the same feature?
> Do you know if this has been planned by bash maintainers?
I think, this is not really needed, since you can get the same effect
using command substitution combined with bc:
#!/bin/bash
pi=$(echo "scale=10; 4*a(1)" | bc -l)
echo $pi
Cheers,
Loic.
| |
| Jon LaBadie 2006-11-25, 7:21 pm |
| loic-dev@gmx.net wrote:
> Hello Antonio,
>
>
> I think, this is not really needed, since you can get the same effect
> using command substitution combined with bc:
>
> #!/bin/bash
>
> pi=$(echo "scale=10; 4*a(1)" | bc -l)
> echo $pi
>
That is not a valid argument.
I can get integer math with expr, why is it in the shell.
I can use /bin/echo, why is it in the shell.
The discussion should be whether it would be used enough,
and would it save sufficient time,
to warrant inclusion in the shell.
I for one think it would, and it is one of the reasons
I use ksh93 rather than bash.
| |
| Old Man 2006-11-25, 7:21 pm |
| Jon LaBadie wrote:
> loic-dev@gmx.net wrote:
>
>
> That is not a valid argument.
>
> I can get integer math with expr, why is it in the shell.
> I can use /bin/echo, why is it in the shell.
>
> The discussion should be whether it would be used enough,
> and would it save sufficient time,
> to warrant inclusion in the shell.
>
> I for one think it would, and it is one of the reasons
> I use ksh93 rather than bash.
Good points to the argument; I completely agree with you. I started
with UNIX in 1975. When KSH came along, I tried it, and have never used
another shell since. I automate everything on SUN, AIX, BSD, HPUX,
Convergent, Motorola, & AT&T using KSH. I have also worked at many
corporations and stayed with KSH through them all. The only thing that
I need KSH to do is a two-dimensional array.
I don't use [[ in my scripts, but should I do so, #!/bin/ksh makes them
portable. Of course, things like "typeset -A" and "declare -a" must be
done; quite lame to think otherwise. However, I simply include an "if"
that says "if shell = ksh, then typeset ... elseif shell = bash, then
declare ... ". The scripts simulate a C/make ifdef to setup for
portable situations. Then, simply copy a base module and keep typing
the new script.
So, to me at least, KSH is a good answer. I think that if bash is going
to truly bash KSH, they have to step up to the functionality that KSH
offers.
Now, I will really start a mess: My shell scripts in KSH will outrun
the same scripts in bash. Argue if you wish; I have tested this several
times.
Now, let the KSH bashers begin.
Old Man
|
|
|
|
|