Re: BASH question

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

 



M.Lewis wrote:
Andy Green wrote:
M.Lewis wrote:

I thought this was simple, but I've not yet been able to figure out what is wrong.

#!/bin/sh

PERMINUTE=$((28.95/432000))

No floating point support :-)  But even then, be liberal with spaces

PERMINUTE=$(( 29 / 432000 ))

-Andy


Thanks Andy, that resolved the error, but returns $PERMINUTE as 0. It should be something like .00067xxxxx. Is there a way to do that?

Thanks,
Mike



This should work for you:

PERMINUTE=$(echo "5 k 28.95 432000 / p" | dc)

I find dc (man dc) very useful for floating point arithmetic.

Khoa


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux