division problem

how can i show the value when i divide a number where the dividend is greater then the divisor. for example...

3 divided by 15 ---> let x=3/15

when i do this in the shell environment it gives me an output of 0.

please help me.

thanks.

I have one sugestion. Use the awk language to solve this problem. Look this :

[witt@root]$ echo 3 15 | awk '{ print $1/$2}'
0.2
[witt@roto]$ echo 1 15 | awk '{ print $1/$2}'
0.0666667

In your script :

result=`echo 3 15 | awk '{ print $1/$2}'`
echo $result

I hope help you

Witt

Yes, I like awk for working with numbers, particularly when I am dealing with other than whole integers.

The answer of zero that you are getting is correct, but simply truncated to a whole integer. You can force a certain number of decimal places by adding zeros to the numerator. But again, the result will be truncated, not rounded:

a=3
b=17
let x=${a}0000/$b
echo $x
1764

thank you very much for the help. i will do all of your suggestions :slight_smile: