bc command

I need to understand the bc command in UNIX. Can someone help me on this one.:cool:

Did you try to use the man page already? bc is a nifty mathematics program that usually serves as a UNIX desktop calculator:

hi, yes I did, but i need that inside a script....this is the problem...and also, if you use a number with a decimal for example 198.7 and 78.5 in a script, how do u use the bc command to use "scale = 3", because in a script you can spesify it as follows :

TOT=` 198.7 / 78.5 | bc`

It will devide the 198 and 78, but throw away the .7 and .5

On command line you can do it :
$bc
scale = 3
198.7 / 78.5
2.531
quit
$

Try using:

TOT=$(echo "scale=3; 198.7/78.5")
echo $TOT
2.531

thanks, but not working,

TOT=$(echo "scale=3; 198.7/78.5")
echo $TOT
scale=3; 198.7/78.5

sorry

Of course I forgot the bc ...

TOT=$(echo "scale=3; 198.7/78.5" | bc)
echo $TOT
2.531

thanks, this is working....will post a qeustion again soon...thanks again:D