PDA

Bekijk de volledige versie : dividing



kamilek
31-08-2005, 10:15
I would like to divide 2 numbers in script. I do it with comand

a=$(($b/$c))
but the result is an integer number and i want to get real number. Is it possible to do it in script without using python etc.?

WVR
31-08-2005, 15:24
I would like to divide 2 numbers in script. I do it with comand

but the result is an integer number and i want to get real number. Is it possible to do it in script without using python etc.?
The traditional way to do this on Unix systems is with bc e.g.
#echo "5 / 3" | bc -l
1.66666666666666666666
However, I doubt that bc is supplied on these minimal Linux based firmwares.

kamilek
01-09-2005, 09:19
The traditional way to do this on Unix systems is with bc e.g.
#echo "5 / 3" | bc -l
1.66666666666666666666
However, I doubt that bc is supplied on these minimal Linux based firmwares.

Ok i have installed BC, but how could I define the precision of the number?

Oleg
01-09-2005, 11:35
I would like to divide 2 numbers in script. I do it with comand

but the result is an integer number and i want to get real number. Is it possible to do it in script without using python etc.?
Use awk then.